summaryrefslogtreecommitdiff
path: root/extra/foobillard/05_foul_explanation
blob: af89c5e957ab7b61911aaaec7b0b818978851e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
Index: foobillard-3.0a/src/billard3d.c
===================================================================
--- foobillard-3.0a.orig/src/billard3d.c	2006-10-12 16:44:17.000000000 +0200
+++ foobillard-3.0a/src/billard3d.c	2006-10-12 16:44:31.000000000 +0200
@@ -331,6 +331,8 @@
 static textObj * winner_name_text_obj;
 static textObj * winner_text_obj;
 
+textObj * last_fault_text;
+
 #ifndef _WIN32
 
 enum optionType
@@ -3322,6 +3324,13 @@
        if( player[act_player].text != 0 ){
            textObj_draw( player[act_player].text );
        }
+       /* last fault */
+       if (strcmp("x", last_fault_text->str)!=0) {
+             glTranslatef(0.0, 70.0, 0.0);
+             textObj_draw(last_fault_text);
+             glTranslatef(0.0,-70.0,0.0);
+       }
+
        glTranslatef(0,30,0);
        if        (gametype==GAME_8BALL){
            switch(player[act_player].half_full){
@@ -5197,6 +5206,9 @@
    }
    DPRINTF("created winner text obj's\n");
 
+
+   last_fault_text = textObj_new( "x", options_help_fontname, 20 );
+
    init_menu();
 
    sys_set_timer(frametime_ms, Idle_timer);     /* assure a framerate of max 50 fps (1frame/20ms) */
Index: foobillard-3.0a/src/evaluate_move.c
===================================================================
--- foobillard-3.0a.orig/src/evaluate_move.c	2006-10-12 16:44:22.000000000 +0200
+++ foobillard-3.0a/src/evaluate_move.c	2006-10-12 16:44:31.000000000 +0200
@@ -4,6 +4,9 @@
 **    Copyright (C) 2001  Florian Berger
 **    Email: harpin_floh@yahoo.de, florian.berger@jk.uni-linz.ac.at
 **
+**    Small changes to output a reason why the last shot was a fault by
+**    Thorsten Gunkel <tgunkel-lists@tgunkel.de>
+**
 **    This program is free software; you can redistribute it and/or modify
 **    it under the terms of the GNU General Public License Version 2 as
 **    published by the Free Software Foundation;
@@ -108,11 +111,12 @@
 
     /* wenn fremde kugel zuerst angespielt -> foul */
     first_ball_hit=BM_get_1st_ball_hit();
-    if( player[act_player].half_full == BALL_FULL ){
-        if ( first_ball_hit>8 && first_ball_hit<16 ) foul=1;
-    }
-    if( player[act_player].half_full == BALL_HALF ){
-        if ( first_ball_hit>0 && first_ball_hit<8 ) foul=1;
+    if(
+       ( player[act_player].half_full == BALL_FULL && first_ball_hit>8 && first_ball_hit<16 ) ||
+       ( player[act_player].half_full == BALL_HALF && first_ball_hit>0 && first_ball_hit<8  )
+       ){
+      foul=1;
+      textObj_setText(last_fault_text, "First ball hit was not one of yours");
     }
 
     /* erst an 2. stelle, da oben kein foul bei break */
@@ -146,7 +150,10 @@
                 }
             }
         }
-        if(eigene_da) foul=1;
+        if(eigene_da){
+          foul=1;
+          textObj_setText(last_fault_text, "You hit the 8-Ball too soon");
+        }
     }
 
     /* wenn angespielte kugel im strafraum */
@@ -154,6 +161,7 @@
         in_strafraum(BM_get_1st_ball_hit_pos()) &&
         !BM_get_non_strafraum_wall_hit_before_1st_ball(in_strafraum) ){
         foul=1;
+        textObj_setText(last_fault_text, "You hit a ball not behind the head string");
     }
 
     /* wenn eigene rein naechster */
@@ -169,7 +177,10 @@
     }
 
 
-    if( BM_get_balls_hit()==0 ) foul=1;
+    if( BM_get_balls_hit()==0 ){
+      foul=1;
+      textObj_setText(last_fault_text, "No Ball hit");
+    }
 
     /* wenn weisse rein */
     if( BM_get_white_out() ){
@@ -177,6 +188,7 @@
         foul=1;
         balls.ball[0].in_game=1;
         balls.ball[0].in_hole=0;
+        textObj_setText(last_fault_text, "White ball potted");
     }
 
     /* wenn foul */
@@ -188,6 +200,8 @@
         balls.ball[0].w=vec_xyz(0.0,0.0,0.0);
         balls.ball[0].r=vec_xyz(0.0,-TABLE_L/4.0,0.0);
 //        balls.ball[0].r=vec_xyz(x,y,0.0);
+    } else {
+      textObj_setText(last_fault_text, "x");
     }
 
     /* if 8 out */
@@ -221,6 +235,7 @@
         else
         {
             player[(act_player==1)?0:1].winner=1;
+            textObj_setText(last_fault_text, "8 ball potted too soon");
         }
 
     }
@@ -277,9 +292,15 @@
         nextplayer=0;
     }
 
-    if( BM_get_balls_hit()==0 ) foul=1;
-
-    if( BM_get_1st_ball_hit()!=minball ) foul=1;
+    if( BM_get_balls_hit()==0 ){
+      textObj_setText(last_fault_text, "No Ball hit");
+      foul=1;
+    } else {
+      if( BM_get_1st_ball_hit()!=minball ){
+        textObj_setText(last_fault_text, "First ball hit was not the lowest");
+        foul=1;
+      }
+    }
 
     /* wenn weisse rein */
     if( BM_get_white_out() ){
@@ -287,6 +308,7 @@
         nextplayer=1;
         pballs->ball[0].in_game=1;
         pballs->ball[0].in_hole=0;
+        textObj_setText(last_fault_text, "White ball is potted");
     }
 
     /* wenn foul - weisse platzieren */
@@ -297,6 +319,8 @@
         pballs->ball[0].v=vec_xyz(0.0,0.0,0.0);
         pballs->ball[0].w=vec_xyz(0.0,0.0,0.0);
         pballs->ball[0].r=vec_xyz(0,-TABLE_L/4.0,0.0);
+    } else {
+      textObj_setText(last_fault_text, "x");
     }
 
     fprintf(stderr,"foul:%d, nextplayer:%d, BM_get_ball_out(9):%d\n",foul,nextplayer,BM_get_ball_out(9));
@@ -409,6 +433,7 @@
         act_penalty =MAX(act_penalty,(BM_get_1st_ball_hit()<=7?BM_get_1st_ball_hit():4));
         spot_snooker_ball(pballs,0);
         player[other_player].place_cue_ball=1;
+        textObj_setText(last_fault_text, "White ball is potted");
     }
 
     switch(st.to_play)
@@ -420,6 +445,11 @@
             foul=1;
             act_penalty=MAX(act_penalty,b1hit);
             printf("EVAL foul 1\n");
+            if( BM_get_balls_hit()==0 ){
+              textObj_setText(last_fault_text, "No Ball hit");
+            } else {
+              textObj_setText(last_fault_text, "First ball hit was not a red one");
+            }
         }
         i=1;
         while((ball_out=BM_get_nth_ball_out(i++))>=0)
@@ -434,6 +464,11 @@
                 act_penalty=MAX(act_penalty,ball_out);
                 foul=1;
                 printf("EVAL foul 2\n");
+                if (BM_get_white_out()){
+                  textObj_setText(last_fault_text, "White ball potted");
+                } else {
+                  textObj_setText(last_fault_text, "Potted ball was not a red one");
+                }
             }
         }
         for(i=2;i<8;i++)
@@ -449,6 +484,11 @@
             foul=1;
             printf("EVAL foul 3\n");
             act_penalty=MAX(act_penalty,7);
+            if( BM_get_balls_hit()==0 ){
+              textObj_setText(last_fault_text, "No Ball hit");
+            } else {
+              textObj_setText(last_fault_text, "First ball hit was not a colored one");
+            }
         }
         color_to_pot=b1hit;
         i=1;
@@ -464,6 +504,11 @@
                 foul=1;
                 printf("EVAL foul 4\n");
                 act_penalty=MAX(act_penalty,ball_out==1?7:ball_out);
+                if (BM_get_white_out()){
+                  textObj_setText(last_fault_text, "White ball potted");
+                } else {
+                  textObj_setText(last_fault_text, "Potted ball was not a colored one");
+                }
             }
         }
         if(red_balls_are_in_game)
@@ -490,6 +535,11 @@
             printf("EVAL foul 5\n");
             act_penalty=MAX(act_penalty,b1hit);
             act_penalty=MAX(act_penalty,color_to_pot);
+            if( BM_get_balls_hit()==0 ){
+              textObj_setText(last_fault_text, "No Ball hit");
+            } else {
+              textObj_setText(last_fault_text, "First ball hit was not the correct one");
+            }
         }
         i=1;
         while((ball_out=BM_get_nth_ball_out(i++))>=0)
@@ -505,6 +555,11 @@
                 printf("EVAL foul 6\n");
                 act_penalty=MAX(act_penalty,b1hit);
                 act_penalty=MAX(act_penalty,color_to_pot);
+                if (BM_get_white_out()){
+                  textObj_setText(last_fault_text, "White ball potted");
+                } else {
+                  textObj_setText(last_fault_text, "Potted ball was not the correct one");
+                }
             }
         }
         if(!foul && act_score>0) st.to_play++;
@@ -528,6 +583,7 @@
     {
         player[act_player].score += act_score ;
         printf("EVAL no foul\n");
+        textObj_setText(last_fault_text, "x");
     }
     if(act_score==0 || foul)
     {
Index: foobillard-3.0a/src/evaluate_move.h
===================================================================
--- foobillard-3.0a.orig/src/evaluate_move.h	2006-10-12 16:44:24.000000000 +0200
+++ foobillard-3.0a/src/evaluate_move.h	2006-10-12 16:44:31.000000000 +0200
@@ -31,6 +31,7 @@
                                     BallsType * pballs, int * pqueue_view, float * pXque );
 #endif
 
+extern textObj * last_fault_text;
 
 void evaluate_last_move_8ball    ( struct Player * player, int * actual_player,
                                    BallsType * pballs, int * pqueue_view, float * pXque );