Skip to content

Commit

Permalink
#206 Started to create nation map.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Apr 15, 2023
1 parent c702698 commit 334acf6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Dev/srcStrat/dless/DLessScen.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright 2018-23 Richard Oliver. Licensed under Apache Licence version 2.0. */
package ostrat; package dless
import prid._, phex._, eg320._, pEarth._, egrid._
import prid._, phex._, eg320._, egrid._

/** Scenario trait for Diceless. */
trait DLessScen extends HSysTurnScen
Expand Down Expand Up @@ -59,6 +59,10 @@ object DLessScen1 extends DLessScen
res.setFSomesMut(Spain.armyNext, 132,508, 130,510)
res
}

val nationMap = gridSys.newHCenLayer[NationOpt](NationLess)
terrs.hcForeach{ (hc, terr) => if(terr.isLand) nationMap.set(hc, Neutral) }
//nationMap.setRowPartSame(138, 510, 3, France)
}

/** 2nd scenario for Diceless. Might have some use. */
Expand Down
19 changes: 17 additions & 2 deletions Dev/srcStrat/dless/Nation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
package ostrat; package dless
import Colour._

trait Nation
trait NationOpt extends Coloured
{ def altColour: Colour = colour
}

object NationLess extends NationOpt
{
override val colour: Colour = DarkBlue
}

trait Nation extends NationOpt
{ val name: String
val colour: Colour

override def toString: String = name
def army(num: Int): Army = Army(this, num)
def armyNext()(implicit counters: ArrCounters[Nation]): Army = army(counters(this))
Expand All @@ -18,6 +27,7 @@ object Britain extends Nation
object France extends Nation
{ override val name: String = "France"
override val colour: Colour = DarkBlue
override def altColour: Colour = LightBlue
}

object Germany extends Nation
Expand Down Expand Up @@ -48,4 +58,9 @@ object Ottoman extends Nation
object Spain extends Nation
{ override val name: String = "Spain"
override val colour: Colour = Orange
}

object Neutral extends Nation
{ override val name: String = "Neutral"
override val colour: Colour = Gray
}
2 changes: 1 addition & 1 deletion Tiling/srcHex/HCenLayer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HCenLayer[A <: AnyRef](val unsafeArray: Array[A]) extends AnyVal with TCen
/** [[HCen]] with foreach. Applies the side effecting function to the [[HCen]] coordinate with its respective element. Note the function signature
* follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element)
* => B signature. */
def hcForeach[U](f: (HCen, A) => U)(implicit grid: HGrid): Unit = grid.iForeach{ (hc, i) => f(hc, unsafeArray(i)); () }
def hcForeach[U](f: (HCen, A) => U)(implicit gSys: HGridSys): Unit = gSys.iForeach{ (hc, i) => f(hc, unsafeArray(i)); () }

/** [[HCen]] with map. Applies the function to each [[HCen]] coordinate with the corresponding element in the underlying array. Note the function
* signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator,
Expand Down
1 change: 1 addition & 0 deletions Util/src/ExtensionsInt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class IntExtensions(val thisInt: Int) extends AnyVal
/** multiplies this Int by a quadrillion and returns the result as [[Long]]. */
def quadrillion: Long = thisInt.toLong * 1000000000000000L

/** Returns a [[String]] of of the given number of space characters. */
def spaces: String = (1 to thisInt).foldLeft("")((a, b) => a + " ")

def scaledStr(pairs: (Int, String)*): String = {
Expand Down

0 comments on commit 334acf6

Please sign in to comment.