Class: Hlockey::Mod::Locked

Inherits:
Object
  • Object
show all
Includes:
Moddable
Defined in:
lib/hlockey/mod/locked.rb

Overview

This player can not swap positions.

Constant Summary collapse

DESCRIPTION =
"This player can not swap positions.".freeze

Instance Attribute Summary

Attributes included from Moddable

#game

Instance Method Summary collapse

Methods included from Moddable

#initialize, #on_action, #on_got_hit, #on_join_fight

Methods included from SelfDescribable

#to_s

Instance Method Details

#on_swap(into_roster, pos, prev_pos) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hlockey/mod/locked.rb', line 12

def on_swap(into_roster, pos, prev_pos)
  swap_player = nil
  if into_roster
    swap_player = @team.shadows[prev_pos]
    @team.roster[pos] = swap_player
    @team.shadows[prev_pos] = @player
  else
    swap_player = @team.roster[prev_pos]
    @team.shadows[pos] = swap_player
    @team.roster[prev_pos] = @player
  end

  send_game_message(:mod_locked_event, player: @player, swap_player:)
end