Update column.c

This commit is contained in:
Jason Bou-Samra
2024-08-30 19:16:48 +10:00
committed by GitHub
parent cfcd8784ac
commit 49d0250c2e
+5 -3
View File
@@ -1,5 +1,7 @@
#include <sodium.h> #include <sodium.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#include "events.h"
/******************** /********************
* tile colours * * tile colours *
@@ -87,14 +89,14 @@ int new_column(void) {
//totcol_avail = 0; //totcol_avail = 0;
count_col(); count_col();
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (colcnt[i] > 2) {totcol_avail++;} // count total available columns if (colcnt[i] > 3) {totcol_avail++;} // count total available columns
} }
if (totcol_avail == 0) { if (totcol_avail == 0) {
printf("game over\n");} else { // no more columns available printf("game over\n"); restart=true;} else { // no more columns available
randc = randombytes_uniform(totcol_avail) + 0; // choose random number from available columns randc = randombytes_uniform(totcol_avail) + 0; // choose random number from available columns
avl = -1; avl = -1;
for (int i = 0; randc != avl; i++) { // translate random num from avail column to actual column for (int i = 0; randc != avl; i++) { // translate random num from avail column to actual column
if (colcnt[i] > 2) {avl++;} if (colcnt[i] > 3) {avl++;}
actual_col = i; // might need to move this down to next brace actual_col = i; // might need to move this down to next brace
} }
} }