Преглед на файлове

created dice object so there are dice for the game.

wes преди 4 години
родител
ревизия
b94348c025
променени са 4 файла, в които са добавени 86 реда и са изтрити 11 реда
  1. 56 0
      Qwixx/dice.cpp
  2. 0 5
      Qwixx/die.cpp
  3. 8 6
      Qwixx/main.cpp
  4. 22 0
      Qwixx/toDo.md

+ 56 - 0
Qwixx/dice.cpp

@@ -0,0 +1,56 @@
+#include <string>
+#include <vector>
+class Dice {
+    public:
+        int white1, white2, red, yellow, green, blue;
+        int roll();
+        void print();
+};
+int Dice::roll() {
+    std::vector<int> output;
+    // generate 6 random numbers to assign to each die
+    for (int i = 0; i<6; i++) {
+        // store numbers generated from rand into output
+        output.push_back((rand() % 6) + 1);
+    }
+    white1 = output[0];
+    white2 = output[1];
+    red = output[2];
+    yellow = output[3];
+    green = output[4];
+    blue = output[5];    
+    return 15;
+}
+void Dice::print() {
+    fprintf (stdout, "White1 Dice: %d\n", white1);
+    fprintf (stdout, "White2 Dice: %d\n", white2);
+    fprintf (stdout, "Yellow Dice: %d\n", yellow);
+    fprintf (stdout, "Red Dice: %d\n", red);
+    fprintf (stdout, "Blue Dice: %d\n", blue);
+    fprintf (stdout, "Green Dice: %d\n", green);
+}
+/* Dice humphe;
+humphe = new Dice();
+humphe.rollDice();
+
+fprintf(stdout, "the red die %d\n", humphe.red);
+
+
+struct SDie {
+    int number;
+    std::string color;
+};
+
+class CDie {
+    int number; std::string color;
+    int roll();
+};
+
+
+SDie greebDie = {1, "brellow"};
+
+CDie yellowDie;
+yellowDie = newC Die();
+yellowDie.number = 1;
+yellowDie.color = "preple";
+yellowDie.roll(); */

+ 0 - 5
Qwixx/die.cpp

@@ -1,5 +0,0 @@
-#include <stdlib.h>
-
-int die (int a){
-    
-}

+ 8 - 6
Qwixx/main.cpp

@@ -1,11 +1,13 @@
 #include <iostream>
 #include <stdlib.h>
 #include <time.h>
+#include <vector>
+#include "dice.cpp"
+std::vector<int> rollDice();
 int main (){
-    fprintf (stdout,"Qwixx initiated!");
+    fprintf (stdout,"Qwixx initiated!\n");
     srand(time(NULL));
-    // print 10 random numbers - however rand in clib is pseudo random
-    for (int i = 0; i<1000; i++) {
-        std::cout << (rand() % 6) + 1 << std::endl;
-    }
-}
+    Dice dice;
+    dice.roll();
+    dice.print();
+}

+ 22 - 0
Qwixx/toDo.md

@@ -0,0 +1,22 @@
+# Start making the player card
+## the game is set up
+- each player gets a card 
+ - called playerCard for player to mark their points
+ - has 4 different colored rows 
+ - rows are numbered 2-12 with boxes for scoring
+- there are six six-sided dice
+ - two white die, a blue, a red, a yellow and green die.
+
+## players take turns
+1.  ~~roll the dice~~ (completed 20JUL28)
+1.  all players may add points to their card
+ - sum both white dice and optionally add points to any color on card
+1.  the player whose turn it is sums one white and one colored dice and may add points to that color on card
+1.  the player whose turn it is adds penalty if no points taken
+1.  scoring phase
+ - at the end of the turn, the game may end if there are enough points on any player's card
+     - if any one player has 4 penalties, the game is over
+     - if any 2 rows are locked out, the game is over
+
+## the game is ended
+- list the scores and indicate the winner