Skip to content

Commit

Permalink
Merge pull request #16 from long74100/reset
Browse files Browse the repository at this point in the history
fix reset
  • Loading branch information
Guo-William authored Mar 27, 2018
2 parents 497d07a + 0117977 commit 919f88c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pokeboot/lib/pokeboot/battle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ defmodule Pokeboot.Battle do
starter = payload["starter"]

if trainer == battle.trainer1.name || trainer == battle.trainer2.name do
if battle.gameOver do
new()
|> loadTrainer(payload)
else
battle
end
battle
else
case battle do
%{trainer1: %Trainer{name: ""}} ->
Expand Down Expand Up @@ -231,7 +226,15 @@ defmodule Pokeboot.Battle do
battle
|> Map.put(:gameOver, true)
else
battle
battle
end
end

def isBattleOver(battle) do
if battle.gameOver == true do
new()
else
battle
end
end

Expand Down
1 change: 1 addition & 0 deletions pokeboot/lib/pokeboot_web/channels/battles_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule PokebootWeb.BattlesChannel do
def join("battles:" <> name, payload, socket) do
if authorized?(payload) do
battle = (BattleRooms.load(name) || Battle.new())
|> Battle.isBattleOver()
|> Battle.loadTrainer(payload)

socket = socket
Expand Down

0 comments on commit 919f88c

Please sign in to comment.