add default goal business cards, allow Board.GetCellsByOwner to accept actor instead of player, rework BusinessCard click to be accepted based on _goalMet instead of Disabled, add default goals to enemy class,
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Enemy : Actor
|
||||
{
|
||||
@@ -7,6 +9,7 @@ public partial class Enemy : Actor
|
||||
public Player _playerOpponent;
|
||||
public Cell _cell;
|
||||
public Enemy _owner;
|
||||
public List<GoalName> _defaultGoals = new();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -14,6 +17,14 @@ public partial class Enemy : Actor
|
||||
_board = GetNode<Board>("Board");
|
||||
_board.ClaimOwnership(this);
|
||||
_board.Disable(true);
|
||||
_defaultGoals.Add(GoalName.TopRow);
|
||||
_defaultGoals.Add(GoalName.MiddleRow);
|
||||
_defaultGoals.Add(GoalName.BottomRow);
|
||||
_defaultGoals.Add(GoalName.LeftColumn);
|
||||
_defaultGoals.Add(GoalName.MiddleColumn);
|
||||
_defaultGoals.Add(GoalName.RightColumn);
|
||||
_defaultGoals.Add(GoalName.Diagonal1To9);
|
||||
_defaultGoals.Add(GoalName.Diagonal3To7);
|
||||
}
|
||||
|
||||
public virtual void PassPlayer(Player PLAYER)
|
||||
@@ -21,6 +32,23 @@ public partial class Enemy : Actor
|
||||
_playerOpponent = PLAYER;
|
||||
}
|
||||
|
||||
public void CheckGoals()
|
||||
{
|
||||
List<Cell> ownedCells = _board.GetCellsByOwner(this);
|
||||
Goal goal = new Goal();
|
||||
for (int i = 0; i < _defaultGoals.Count; i++)
|
||||
{
|
||||
GoalName goalName = _defaultGoals[i];
|
||||
List<int> addresses = goal.GetAddresses(goalName);
|
||||
bool goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1);
|
||||
if (goalMet)
|
||||
{
|
||||
Victory(goalName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ClickCell(Cell CLICKEDCELL)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user