Advertisement
Guest User

Untitled

a guest
Jul 16th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.91 KB | None | 0 0
  1. type Update= (TileType, Seq[MineralDrop], Int, Boolean)
  2. def standard(f:( ((Int,Int), Int) => (TileType, Int, Boolean))): ((Int,Int), Int) => Update = { case (ij, dmg) =>
  3.     val (tt, toolDmg, broke) = f(ij, dmg)
  4.     (tt, Seq(), toolDmg, broke)
  5.   }
  6.  
  7. case class Rock3(override val tile:Tile, override val bg:Tile, hp:Int) extends TileType {
  8.   val toolDamage = 50
  9.   override def hit: ((Int, Int), Int) => Update = standard { case (ij, dmg) =>
  10.     val newHp = hp.drop(dmg)
  11.     if (newHp > 0) {
  12.       (copy(hp = newHp), toolDamage, false)
  13.     } else {
  14.       (Empty(bg), toolDamage, true)
  15.     }
  16.   }
  17. }
  18.  
  19. //Error:(36, 12) class Rock3 needs to be abstract, since method hit in trait TileType of type (ij: (Int, Int), dmg: Int)(in.dogue.profundus.world.TileType, Seq[in.dogue.profundus.entities.MineralDrop], Int, Boolean) is not defined
  20. //case class Rock3(override val tile:Tile, override val bg:Tile, hp:Int) extends TileType {
  21. //           ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement