Skip to content

Instantly share code, notes, and snippets.

@sdebaun
Last active August 18, 2020 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdebaun/02331123b2bb163cc8615ef422710a4d to your computer and use it in GitHub Desktop.
Save sdebaun/02331123b2bb163cc8615ef422710a4d to your computer and use it in GitHub Desktop.

I focused on these methods that you changed with an eye towards how those refactorings expose other opportunities. I surveyed both their callers and their callees

GetRunMovesForReserveUnit(playerId, Unit, isVanguard)

What is calling it:

  • GetHexesForVanguard(Unit) -- GetRunMovesForReserveUnit(unit.owningPlayerId, unit, true)
  • GetActionableHexesForReserveUnit(PTD, Unit, HS x3) -- GetRunMovesForReserveUnit(unit.owningPlayerId, unit, false)

What it is doing:

  • playerId is irrelevant, both callers are just passing unit.owningPlayerId
  • it actually contains logic to check vanguard and use 2 instead of actual walks
  • its pulling in a set of start hexes from gm.ReservesForPlayer(playerId)
  • so its effectively: (Unit, List) => List
  • delegating actual generation of list to GetHexesInRange(playerId, ht, min, max, allTerrain, vanguard, vanguard)

GetJumpMovesForReserveUnit(Unit)

What is calling it:

  • GetActionableHexesForReserveUnit(PTD, Unit, HS x3) -- GetJumpMovesForReserveUnit(unit)
  • MoveAction:DetermineMovementPathForReserveUnit(isVanguard, PTD) ??? -- GetJumpMovesForReserveUnit(unit)

What it is doing:

  • also pulling in gm.ReservesForPlayer
  • effectively making it (Unit, List) => List
  • and delegating to GetHexesInRangeForJump(unit.owningPlayerId, ht, unit)

GetInsertMovesForReserveUnit(playerId, PTD)

What is calling it:

  • GetActionableHexesForReserveUnit(PTD, Unit, HS x3) -- GetInsertMovesForReserveUnit(unit.owningPlayerId, turnData)
  • MoveAction:DetermineMovementPathForReserveUnit(isVanguard, PTD) -- GetInsertMovesForReserveUnit(baseData.playerId, turnData)

What it is doing:

  • getting a list of potential source hexes from PlayersUnitsOnMap(playerId), similar to gm.ReservesForPlayer
  • effectively List => List (no Unit bc dont need walks or runs or nuttin)
  • uses HexMap.GetNeighbors(ht) and filters out hts with units or in reserves, nice

GetHexesForVanguard(Unit)

What is calling it:

  • ONLY GetActionableHexesForReserveUnit (covered above)

What it is doing:

  • does checking of whether or not a vanguard move can be made with that unit
  • and then passes through to GetRunMovesForReserveUnit with a vanguard=true flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment