added readme

This commit is contained in:
2024-04-24 19:16:56 -05:00
parent e25e7da40f
commit 8753d6134d
3 changed files with 114 additions and 20 deletions

50
game.cs
View File

@@ -2,6 +2,7 @@ using Godot;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Linq;
@@ -56,22 +57,22 @@ public partial class game : Control
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
var rows = this.GetAllDescendents<row>().ToArray();
for (int i = 0; i < 20; i++)
{
var c = card.MakeCard(GetTree());
c.CardName = $"Card {c.CardId}";
if (GD.RandRange(0, 1) == 1)
{
//add to a row
var r = rows[GD.RandRange(0, rows.Length - 1)];
r.AddCard(c);
}
else
{
AddUnassignedCard(c);
}
}
// var rows = this.GetAllDescendents<row>().ToArray();
// for (int i = 0; i < 20; i++)
// {
// var c = card.MakeCard(GetTree());
// c.CardName = $"Card {c.CardId}";
// if (GD.RandRange(0, 1) == 1)
// {
// //add to a row
// var r = rows[GD.RandRange(0, rows.Length - 1)];
// r.AddCard(c);
// }
// else
// {
// AddUnassignedCard(c);
// }
// }
PropogateCardSize();
@@ -222,13 +223,22 @@ public partial class game : Control
#region Commands
public void MoveCard(string cardId, string targetRowId, int? toIndex = null)
{
var r = FindRow(targetRowId);
if (r is null)
throw new Exception($"row {r.RowId} not found");
row r;
if (targetRowId == "_")
r = null;
else
{
r = FindRow(targetRowId);
if (r is null)
throw new Exception($"row {r.RowId} not found");
}
var c = ClaimCard(cardId);
if (c is null)
throw new Exception($"card {c.CardId} not found");
r.AddCard(c, toIndex);
if (r is not null)
r.AddCard(c, toIndex);
else
AddUnassignedCard(c);
}
public void MoveRow(string rowId, int toIndex)
{