2026-04-10 14:58:03 +02:00
|
|
|
using Godot;
|
|
|
|
|
using Chessistics.Engine.Model;
|
|
|
|
|
using Chessistics.Scripts.Board;
|
|
|
|
|
|
|
|
|
|
namespace Chessistics.Scripts.Pieces;
|
|
|
|
|
|
|
|
|
|
public partial class PieceView : Node2D
|
|
|
|
|
{
|
|
|
|
|
private Sprite2D _sprite = null!;
|
|
|
|
|
private ColorRect _cargoIndicator = null!;
|
|
|
|
|
private Label _label = null!;
|
|
|
|
|
|
|
|
|
|
public int PieceId { get; private set; }
|
|
|
|
|
public PieceKind Kind { get; private set; }
|
|
|
|
|
public Coords StartCell { get; private set; }
|
|
|
|
|
public Coords EndCell { get; private set; }
|
|
|
|
|
|
Add Pion piece, surplus stock, and levels 4-6
- Pion (Pawn): orthogonal range 1, social status 1 (lowest), green color
- All existing levels get surplus stock including pawns for player choice
- Level 4 "Le Carrefour": 8x8, dual cargo diagonal routes, center wall block
- Level 5 "Le Labyrinthe": 8x6, wall corridors, knights essential for shortcuts
- Level 6 "Trois Royaumes": 10x8, 3 productions + 3 demands, full network puzzle
- Production interval concept removed (all produce every turn)
- GDD updated with Pion section and 6 level descriptions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 22:03:36 +02:00
|
|
|
private static readonly Color PawnColor = new("#7AB54A");
|
2026-04-10 14:58:03 +02:00
|
|
|
private static readonly Color RookColor = new("#4A7AB5");
|
|
|
|
|
private static readonly Color BishopColor = new("#B54A8E");
|
|
|
|
|
private static readonly Color KnightColor = new("#B5824A");
|
|
|
|
|
private static readonly Color WoodCargoColor = new("#8B6914");
|
|
|
|
|
private static readonly Color StoneCargoColor = new("#808080");
|
|
|
|
|
|
|
|
|
|
public void Setup(int pieceId, PieceKind kind, Coords startCell, Coords endCell, BoardView boardView)
|
|
|
|
|
{
|
|
|
|
|
PieceId = pieceId;
|
|
|
|
|
Kind = kind;
|
|
|
|
|
StartCell = startCell;
|
|
|
|
|
EndCell = endCell;
|
|
|
|
|
|
|
|
|
|
Position = boardView.CoordsToPixel(startCell);
|
|
|
|
|
|
|
|
|
|
var color = kind switch
|
|
|
|
|
{
|
Add Pion piece, surplus stock, and levels 4-6
- Pion (Pawn): orthogonal range 1, social status 1 (lowest), green color
- All existing levels get surplus stock including pawns for player choice
- Level 4 "Le Carrefour": 8x8, dual cargo diagonal routes, center wall block
- Level 5 "Le Labyrinthe": 8x6, wall corridors, knights essential for shortcuts
- Level 6 "Trois Royaumes": 10x8, 3 productions + 3 demands, full network puzzle
- Production interval concept removed (all produce every turn)
- GDD updated with Pion section and 6 level descriptions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 22:03:36 +02:00
|
|
|
PieceKind.Pawn => PawnColor,
|
2026-04-10 14:58:03 +02:00
|
|
|
PieceKind.Rook => RookColor,
|
|
|
|
|
PieceKind.Bishop => BishopColor,
|
|
|
|
|
PieceKind.Knight => KnightColor,
|
|
|
|
|
_ => Colors.White
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Piece body (circle)
|
|
|
|
|
_sprite = new Sprite2D();
|
|
|
|
|
var texture = new GradientTexture2D
|
|
|
|
|
{
|
|
|
|
|
Width = 48,
|
|
|
|
|
Height = 48,
|
|
|
|
|
Fill = GradientTexture2D.FillEnum.Radial,
|
|
|
|
|
Gradient = new Gradient()
|
|
|
|
|
};
|
|
|
|
|
texture.Gradient.SetColor(0, color);
|
|
|
|
|
texture.Gradient.SetColor(1, color.Darkened(0.3f));
|
|
|
|
|
_sprite.Texture = texture;
|
|
|
|
|
AddChild(_sprite);
|
|
|
|
|
|
|
|
|
|
// Label
|
|
|
|
|
_label = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = kind switch
|
|
|
|
|
{
|
Add Pion piece, surplus stock, and levels 4-6
- Pion (Pawn): orthogonal range 1, social status 1 (lowest), green color
- All existing levels get surplus stock including pawns for player choice
- Level 4 "Le Carrefour": 8x8, dual cargo diagonal routes, center wall block
- Level 5 "Le Labyrinthe": 8x6, wall corridors, knights essential for shortcuts
- Level 6 "Trois Royaumes": 10x8, 3 productions + 3 demands, full network puzzle
- Production interval concept removed (all produce every turn)
- GDD updated with Pion section and 6 level descriptions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 22:03:36 +02:00
|
|
|
PieceKind.Pawn => "P",
|
2026-04-10 14:58:03 +02:00
|
|
|
PieceKind.Rook => "T",
|
|
|
|
|
PieceKind.Bishop => "F",
|
|
|
|
|
PieceKind.Knight => "C",
|
|
|
|
|
_ => "?"
|
|
|
|
|
},
|
|
|
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
|
|
|
VerticalAlignment = VerticalAlignment.Center,
|
2026-04-10 21:44:12 +02:00
|
|
|
Position = new Vector2(-8, -10),
|
|
|
|
|
MouseFilter = Control.MouseFilterEnum.Ignore
|
2026-04-10 14:58:03 +02:00
|
|
|
};
|
|
|
|
|
_label.AddThemeFontSizeOverride("font_size", 16);
|
|
|
|
|
_label.AddThemeColorOverride("font_color", Colors.White);
|
|
|
|
|
AddChild(_label);
|
|
|
|
|
|
|
|
|
|
// Cargo indicator (hidden by default)
|
|
|
|
|
_cargoIndicator = new ColorRect
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(14, 14),
|
|
|
|
|
Position = new Vector2(-7, -30),
|
2026-04-10 21:44:12 +02:00
|
|
|
Visible = false,
|
|
|
|
|
MouseFilter = Control.MouseFilterEnum.Ignore
|
2026-04-10 14:58:03 +02:00
|
|
|
};
|
|
|
|
|
AddChild(_cargoIndicator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCargo(CargoType? cargo)
|
|
|
|
|
{
|
|
|
|
|
if (cargo == null)
|
|
|
|
|
{
|
|
|
|
|
_cargoIndicator.Visible = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_cargoIndicator.Visible = true;
|
|
|
|
|
_cargoIndicator.Color = cargo.Value switch
|
|
|
|
|
{
|
|
|
|
|
CargoType.Wood => WoodCargoColor,
|
|
|
|
|
CargoType.Stone => StoneCargoColor,
|
|
|
|
|
_ => Colors.White
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AnimateMoveTo(Vector2 target, float duration = 0.3f)
|
|
|
|
|
{
|
|
|
|
|
var tween = CreateTween();
|
|
|
|
|
if (Kind == PieceKind.Knight)
|
|
|
|
|
{
|
|
|
|
|
// Arc animation for knight
|
|
|
|
|
var mid = (Position + target) / 2 + new Vector2(0, -30);
|
|
|
|
|
tween.TweenMethod(Callable.From<float>(t =>
|
|
|
|
|
{
|
|
|
|
|
var a = Position.Lerp(mid, t);
|
|
|
|
|
var b = mid.Lerp(target, t);
|
|
|
|
|
Position = a.Lerp(b, t);
|
|
|
|
|
}), 0f, 1f, duration);
|
|
|
|
|
tween.Finished += () => Position = target;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tween.TweenProperty(this, "position", target, duration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|