Merge pull request 'Randomized who starts the fight' (#41) from randomise_fight_start into develop

Reviewed-on: #41
Reviewed-by: kziolkowski <katharina.ziolkowski@gmail.com>
develop
Jonathan 4 weeks ago
commit edc133749f

@ -307,6 +307,11 @@ public partial class FightHappening : Node
HappeningData.enemyFighterFormation.SetFighterAtPosition(emptySlotIndex, fighter);
HappeningData.fighterTurn.AddAsLast(fighter);
}
if (GD.RandRange(0, 2) != 0) // 2/3 chance for vesna to start
{
HappeningData.fighterTurn.SpinBack();
}
}
private void ExecuteNextFighter()

@ -99,6 +99,23 @@ public class FighterTurn : IEnumerable<FightWorld.Fighter>
return false;
}
/// <summary>
/// Sets the current one back
/// This is an expensive operation, because the entire data structure needs to be circled
/// </summary>
public void SpinBack()
{
if (_currentNode == null) return;
var node = _currentNode;
while (node.next != _currentNode)
{
node = node.next;
}
_currentNode = node;
}
public IEnumerator<FightWorld.Fighter> GetEnumerator()
{
if (_currentNode == null) return Enumerable.Empty<FightWorld.Fighter>().GetEnumerator();

Loading…
Cancel
Save