DEV Community

loading...

Discussion on: Daily Challenge #43 - Boardgame Fight Resolver

Collapse
hanachin profile image
Seiei Miyagi

ruby <3

Swordsman, Cavalry, Archer, Pikeman = :swardsman, :cavalry, :archer, :pikeman

def fightResolve(attacking_piece, defending_piece)
  case [attacking_piece, defending_piece]
  when [Swordsman, Archer],
       [Pikeman, Swordsman],
       [Cavalry, Pikeman],
       [Archer, Cavalry]
    defending_piece
  else
    attacking_piece
  end
end
Collapse
citizen428 profile image
Michael Kohl

This looks quite similar to my F# solution, I like it. :-)