This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using ServiceStack; | |
using ServiceStack.Text; | |
public class MoveTypeTargets { | |
public HashSet<HexTile> walk = new HashSet<HexTile>(); | |
public HashSet<HexTile> run = new HashSet<HexTile>(); | |
public HashSet<HexTile> jump = new HashSet<HexTile>(); | |
// if you treat these as immutable data objects theres also this sexy: | |
public static MoveTypeTargets None = new MoveTypeTargets(); | |
} | |
public class AttackTypeTargets { | |
public HashSet<HexTile> cc = new HashSet<HexTile>(); | |
public HashSet<HexTile> ra = new HashSet<HexTile>(); | |
} | |
public class HexMap { | |
// ... | |
// keep same signature | |
public void GetActionableHexes(PTD turnData, HexTile tileToSelect, bool allowedToMove) // + a bunch of outs | |
{ | |
//...allowedToAttack and allowedToMove are already defined and involve multiple domains | |
// allowedToMove should probably take into account !(isVanguard && unit.HQ) and other check in GetHexesForVanguard | |
AttackTypeTargets attacks = allowedToAttack ? | |
AttackTypeTargetsFor(turnData, unit, isStationary: turnData.something) : // aim++ cares | |
AttackTypeTargets.None | |
bool isEngaged = attacks.cc.Count > 0; | |
MoveTypeTargets moves = allowedToMove ? | |
MoveTypeTargetsFor(turnData, unit, isEngaged, isVanguard: turnData.something) : // for vanguard calculation | |
MoveTypeTargets.None; | |
ccAttackable = attacks.cc; | |
// etc | |
} | |
public AttackTypeTargets AttackTypeTargetsFor(PTD turnData, Unit unit, bool isStationary) | |
{ | |
} | |
public MoveTypeTargets MoveTypeTargetsFor(PTD turnData, Unit unit, bool isEngaged, bool isVanguard) { | |
if (isVanguard) // return a fixed set of the first two rows - dynamic set of hexes with units | |
return new MoveTypeTargets { | |
run = VanguardHexesWithNoUnits(unit.owningPlayerId) // isnt this all derived from hexmap state? | |
} | |
return new MoveTypeTargets { | |
walk = isEngaged ? | |
HashSet<HexTile>.Empty : | |
(unit.jump > 0) ? | |
HexesInMoveRangeFor(turnData, unit, from: 1, length: 1) : | |
HexesInMoveRangeFor(turnData, unit, from: 1, length: unit.walk) | |
run = isEngaged ? | |
HashSet<HexTile>.Empty : | |
GetMoveableHexes(turnData, unit, from: unit.walk + 1, length: unit.run) | |
jump = HexesInMoveRangeFor(turnData, unit, from: 1, length: unit.jump, ignoreTerrain: true) | |
} | |
} | |
public HashSet<HexTile> HexesInMoveRangeFor(PTD turnData, Unit unit, int from, int length, bool ignoreTerrain = false) => | |
GetHexesInRange(unit.owningPlayerId, unit.hexTile, | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment