[four-in-a-row/KaKnife/four-in-a-row-vala: 33/65] fixed issue with scorebox crashing on game over



commit a88708163ef18f5bd7ee5e5244731b4c0c5f20c4
Author: Jacob Humphrey <jacob ryan humphrey gmail com>
Date:   Fri Dec 14 20:16:18 2018 -0600

    fixed issue with scorebox crashing on game over

 src/main.vala     |  5 +++++
 src/scorebox.vala | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/main.vala b/src/main.vala
index 5ac3605..537de75 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -79,6 +79,11 @@ class FourInARow : Gtk.Application {
     PlayerID player;
     PlayerID winner;
     public PlayerID who_starts;
+    /**
+     * socre:
+     *
+     * The scores for the current instance (Player 1, Player 2, Draw)
+     */
     public int score[3];
     static AnimID anim;
     char vstr[53];
diff --git a/src/scorebox.vala b/src/scorebox.vala
index 0f60097..c35b1f9 100644
--- a/src/scorebox.vala
+++ b/src/scorebox.vala
@@ -82,6 +82,11 @@ class Scorebox : Gtk.Dialog {
         application = global::application;
     }
 
+    /**
+     * update:
+     *
+     * updates the scorebox with the latest scores
+     */
     public void update() {
         if (p.get_n_human_players() == 1) {
             if (p.level[PlayerID.PLAYER1] == Level.HUMAN) {
@@ -96,9 +101,9 @@ class Scorebox : Gtk.Dialog {
             label_name[PlayerID.PLAYER2].label = theme_get_player(PlayerID.PLAYER2);
         }
 
-        label_score[PlayerID.PLAYER1].label = (string)global::application.score[PlayerID.PLAYER1];
-        label_score[PlayerID.PLAYER2].label = (string)application.score[PlayerID.PLAYER2];
-        label_score[PlayerID.NOBODY].label = (string)application.score[PlayerID.NOBODY];
+        label_score[PlayerID.PLAYER1].label = application.score[PlayerID.PLAYER1].to_string();
+        label_score[PlayerID.PLAYER2].label = application.score[PlayerID.PLAYER2].to_string();
+        label_score[PlayerID.NOBODY].label = application.score[PlayerID.NOBODY].to_string();
 
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]