浏览代码

added storage to playercard to save the current selection.

wes 4 年之前
父节点
当前提交
3167345975
共有 2 个文件被更改,包括 23 次插入3 次删除
  1. 21 3
      Qwixx/playerCard.cpp
  2. 2 0
      Qwixx/playerCard.h

+ 21 - 3
Qwixx/playerCard.cpp

@@ -1,13 +1,31 @@
 #include "playerCard.h"
-PlayerCard::PlayerCard(std::string name){
+PlayerCard::PlayerCard(std::string name)
+{
     // make 12 boxes for each colored row (not the white ones)
-    for(int j = 0; j<white1; j++){  
+    for(int j = 0; j<white1; j++)
+    {  
         std::vector<bool> empty;
         rowColors.push_back(empty);  
-        for (int i = 0; i<CHECKBOXES; i++){
+        for (int i = 0; i<CHECKBOXES; i++)
+        {
             rowColors[j].push_back(false);
         }
     }
+    // initialize player selection (this is player's current selected checkbox)
+    std::vector<int> t;
+    t.push_back(0);
+    selection.push_back(t);
+    t.push_back(0);
+    selection.push_back(t);
+    selection.push_back(t);
     savedName = name;
     penaltyCount = 0;
+}
+void PlayerCard::newSelection()
+{
+    selection[penalty][0] = 0;
+    selection[everyone][row] = -1;
+    selection[everyone][column] = -1;
+    selection[active][row] = -1;
+    selection[active][column] = -1;
 }

+ 2 - 0
Qwixx/playerCard.h

@@ -11,5 +11,7 @@
         std::string savedName;
         bool isTurnDone;
         int score;
+        std::vector<std::vector <int>> selection;
+        void newSelection();
     };
 #endif