Skip to content

Commit

Permalink
bug when card count is "windowed", closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
bmichotte committed Apr 1, 2015
1 parent 71ef43f commit 72f8aeb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
11 changes: 9 additions & 2 deletions app/controllers/trackers/opponent_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def game_end(_)
def game_start
Log.verbose 'Opponent reset card'
@cards = []
@table_view.reloadData

unless Configuration.fixed_window_names
self.window.title = 'HSTracker'
end
Expand All @@ -77,6 +77,7 @@ def game_start
self.hand_count = 0
self.deck_count = 30
display_count
@table_view.reloadData
end

def set_hero(player, hero_id)
Expand All @@ -92,16 +93,19 @@ def draw_card(_)
self.hand_count += 1
self.deck_count -= 1 unless self.deck_count.zero?
display_count
@table_view.reloadData
end

def play_secret
self.hand_count -= 1 unless self.hand_count.zero?
display_count
@table_view.reloadData
end

def card_stolen(_)
self.hand_count += 1
display_count
@table_view.reloadData
end

def discard_card(card_id)
Expand All @@ -110,6 +114,7 @@ def discard_card(card_id)

self.hand_count -= 1 unless self.hand_count.zero?
display_count
@table_view.reloadData
end

def secret_revealed(card_id)
Expand Down Expand Up @@ -137,12 +142,14 @@ def play_card(card_id)

self.hand_count -= 1 unless self.hand_count.zero?
display_count
@table_view.reloadData
end

def restore_card(_)
self.deck_count += 1
self.hand_count -= 1 unless self.hand_count.zero?
display_count
@table_view.reloadData
end

def get_coin(_)
Expand All @@ -151,6 +158,7 @@ def get_coin(_)
self.has_coin = true
self.deck_count += 1
display_count
@table_view.reloadData
end

def display_count
Expand All @@ -161,7 +169,6 @@ def display_count

@count_text = text

@table_view.reloadData
end
end

Expand Down
22 changes: 14 additions & 8 deletions app/controllers/trackers/player_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def selectionShouldChangeInTableView(tableView)
# game events
def game_end(_)
if Configuration.reset_on_end
@count_text = nil
@count_text = nil
game_start
end
end
Expand All @@ -113,11 +113,7 @@ def game_start
self.deck_count = 30
display_count

Dispatch::Queue.main.after(1) do
@table_view.beginUpdates
@table_view.reloadData
@table_view.endUpdates
end
@table_view.reloadData
end

def set_hero(player, hero_id)
Expand Down Expand Up @@ -146,11 +142,15 @@ def draw_card(card_id)
def play_secret
self.hand_count -= 1 unless self.hand_count.zero?
display_count

@table_view.reloadData
end

def card_stolen(_)
self.hand_count += 1
display_count

@table_view.reloadData
end

def discard_card(card_id)
Expand All @@ -159,6 +159,8 @@ def discard_card(card_id)

self.hand_count -= 1 unless self.hand_count.zero?
display_count

@table_view.reloadData
end

def play_card(card_id)
Expand All @@ -175,6 +177,8 @@ def play_card(card_id)

self.hand_count -= 1 unless self.hand_count.zero?
display_count

@table_view.reloadData
end

def restore_card(card_id)
Expand All @@ -190,6 +194,8 @@ def restore_card(card_id)
self.deck_count += 1
self.hand_count -= 1 unless self.hand_count.zero?
display_count

@table_view.reloadData
end

def get_coin(_)
Expand All @@ -198,6 +204,8 @@ def get_coin(_)
self.has_coin = true
self.deck_count += 1
display_count

@table_view.reloadData
end

def display_count
Expand All @@ -207,8 +215,6 @@ def display_count
text << ("#{'Deck : '._} #{self.deck_count}")

@count_text = text

@table_view.reloadData
end
end

Expand Down

0 comments on commit 72f8aeb

Please sign in to comment.