Created
September 15, 2015 12:32
-
-
Save arturaz/af4dba573d3dd1c85a3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
case class Resources( | |
food: Food=Food(0), wood: Wood=Wood(0), stone: Stone=Stone(0), gold: Gold=Gold(0), | |
mana: Mana=Mana(0) | |
) { | |
def +(r: Resources) = | |
Resources(food + r.food, wood + r.wood, stone + r.stone, gold + r.gold, mana + r.mana) | |
def -(r: Resources) = | |
Resources(food - r.food, wood - r.wood, stone - r.stone, gold - r.gold, mana - r.mana) | |
def >=(r: Resources) = | |
food >= r.food && wood >= r.wood && stone >= r.stone && gold >= r.gold && mana >= r.mana | |
def <(r: Resources) = ! >=(r) | |
def isZero = food.isZero && wood.isZero && stone.isZero && gold.isZero && mana.isZero | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment