Skip to content

Commit

Permalink
#206 More implementation and tests for findStep and findStepEnd on EG…
Browse files Browse the repository at this point in the history
…ridLongMan. Unit movement now seems to be working correctly, just need to account for seas.
  • Loading branch information
Rich2 committed Feb 26, 2023
1 parent d227f71 commit 72ec80d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
6 changes: 1 addition & 5 deletions Dev/srcGrand/dless/DLessGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ case class DLessGui(canv: CanvasPlatform, scenIn: DLessScen, viewIn: HGView, isF
}

case (RightButton, AnyArrHead(HCenPair(hc1, pl: Army)), hits) => hits.findHCenForEach { hc2 =>
val newM: Option[HStep] =
{ val ost = gridSys.findStep(hc1, hc2)
debvar(ost)
ost
}
val newM: Option[HStep] = gridSys.findStep(hc1, hc2)
newM.foreach { d => moves = moves.replaceA1byA2OrAppend(pl, hc1.andStep(d)) }
repaint()
}
Expand Down
6 changes: 2 additions & 4 deletions Dev/srcGrand/dless/DLessScen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ trait DLessScen extends HSysTurnScen
val armies: HCenOptLayer[Army]

def endTurn(orderList: HCenStepPairArr[Army]): DLessScen =
{ val playersKey = armies.somePairs
val targets: HCenBuffLayer[HCenStep] = gridSys.newHCenArrOfBuff
{ val targets: HCenBuffLayer[HCenStep] = gridSys.newHCenArrOfBuff

orderList.foreach { pair =>
val hc1: HCen = playersKey.a2GetA1(pair.a2)
val optTarget: Option[HCen] = hc1.stepOpt(pair.step)
val optTarget: Option[HCen] = pair.startHC.stepOpt(pair.step)
optTarget.foreach { target => targets.appendAt(target, pair.a1) }
}

Expand Down
2 changes: 2 additions & 0 deletions EGrid/TestSrc/eg320/EGridTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ object EGridTest extends TestSuite
sys.findStep(144, 1528, 146, 522) ==> Some(HexUL)
sys.findStep(134, 526, 132, 1524) ==> Some(HexDR)
sys.findStep(136, 1524, 134, 526) ==> Some(HexDL)
sys.findStep(144, 1528, 142, 1526) ==> Some(HexDL)
}

test("findStepEnd")
Expand All @@ -31,6 +32,7 @@ object EGridTest extends TestSuite
sys.findStepEnd(144, 1528, HexUL) ==> Some(HCen(146, 522))
sys.findStepEnd(134, 526, HexDR) ==> Some(HCen(132, 1524))
sys.findStepEnd(136, 1524, HexDL) ==> Some(HCen(134, 526))
sys.findStepEnd(144, 1528, HexDL) ==> Some(HCen(142, 1526))

sys.findStepEnd(140, 524, HexUR) ==> Some(HCen(142, 1526))
sys.findStepEnd(142, 1526, HexRt)==> Some(HCen(142, 1530))
Expand Down
2 changes: 2 additions & 0 deletions Tiling/src/phex/HCenStep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ object HCenStepBuff
{ def apply(initLen: Int = 4) = new HCenStepBuff(new ArrayBuffer[Int](initLen * 3))
}

/** A pair where a1 is an [[HCenStep]] hex grid step representing the starting [[HCen]] of the step as well as the [[HStep]] singleton object itself. */
class HCenStepPair[A2](val a1Int1: Int, val a1Int2: Int, val a1Int3: Int, val a2: A2) extends Int3PairElem[HCenStep, A2]
{ inline def r1: Int = a1Int1
inline def c1: Int = a1Int2
inline def stepInt: Int = a1Int3
def startHC: HCen = HCen(r1, c1)
override def a1: HCenStep = new HCenStep(a1Int1, a1Int2, a1Int3)
def step: HStep = HStep.fromInt(a1Int3)
}
Expand Down

0 comments on commit 72ec80d

Please sign in to comment.