mirror of
https://codeberg.org/Ikatono/TierMaker.git
synced 2025-10-28 20:45:35 -05:00
added readme
This commit is contained in:
50
game.cs
50
game.cs
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user