Skip to content

Commit

Permalink
Fix warnings about positional parameter mismatch (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Oct 20, 2022
1 parent 92cc5c7 commit 0b67f3f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion behavioral/interpreter.cr
Expand Up @@ -60,7 +60,7 @@ abstract class Evaluator
end

class TerminalExpression < Evaluator
def evaluate(_press)
def evaluate(press)
if special_move
context.moves << special_move.as(Move)
else
Expand Down
12 changes: 6 additions & 6 deletions behavioral/mediator.cr
Expand Up @@ -52,12 +52,12 @@ class Match < MediatorBase
end
end

def perform_move(move, fighter)
if can_perform_move?(move, fighter)
if (fighter == player1)
player2.as(Fighter).receive(move, fighter)
elsif (fighter == player2)
player1.as(Fighter).receive(move, fighter)
def perform_move(move, performer)
if can_perform_move?(move, performer)
if (performer == player1)
player2.as(Fighter).receive(move, performer)
elsif (performer == player2)
player1.as(Fighter).receive(move, performer)
end
else
puts "Ignoring move"
Expand Down
16 changes: 8 additions & 8 deletions behavioral/strategy.cr
Expand Up @@ -35,19 +35,19 @@ abstract class FightStrategy
end

class Puncher < FightStrategy
def attack(ft, op)
puts "#{ft.name} attacks #{op.name} with 1 punch."
op.damage(HITS[:punch])
def attack(fighter, opponent)
puts "#{fighter.name} attacks #{opponent.name} with 1 punch."
opponent.damage(HITS[:punch])
end
end

class Combo < FightStrategy
def attack(ft, op)
puts "#{ft.name} attacks #{op.name} with 2 kicks and 1 punch."
def attack(fighter, opponent)
puts "#{fighter.name} attacks #{opponent.name} with 2 kicks and 1 punch."

op.damage(HITS[:kick])
op.damage(HITS[:kick])
op.damage(HITS[:punch])
opponent.damage(HITS[:kick])
opponent.damage(HITS[:kick])
opponent.damage(HITS[:punch])
end
end

Expand Down
3 changes: 1 addition & 2 deletions structural/flyweight.cr
Expand Up @@ -23,8 +23,7 @@ class Tree < FlyweightTree
@pos = {0, 0}
end

def draw_at(_pos : Position)
pos = _pos
def draw_at(pos : Position)
puts "Drawing #{@species} at #{pos}"
end
end
Expand Down

0 comments on commit 0b67f3f

Please sign in to comment.