-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconstraint.c
More file actions
executable file
·47 lines (37 loc) · 1004 Bytes
/
constraint.c
File metadata and controls
executable file
·47 lines (37 loc) · 1004 Bytes
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
/* constraint.c */
#include <stdlib.h>
#include "array.h"
#include "baize.h"
#include "constraint.h"
#include "trace.h"
_Bool CanTailBeMoved(struct Array *const tail)
{
struct Card *const c0 = ArrayGet(tail, 0);
// BaizeTouchStop() checks if any tail cards are prone
struct Pile *const pile = CardOwner(c0);
struct Baize *const baize = PileOwner(pile);
const char *strerr = baize->script->TailMoveError(tail);
if (strerr) {
BaizeSetError(baize, strerr);
return 0;
}
return 1;
}
_Bool CanTailBeAppended(struct Pile *const pile, struct Array *const tail)
{
if (!PileValid(pile)) {
CSOL_ERROR("%s", "invalid pile");
return 0;
}
if (!tail) {
CSOL_ERROR("%s", "invalid tail");
return 0;
}
struct Baize *const baize = PileOwner(pile);
const char *strerr = baize->script->TailAppendError(pile, tail);
if (strerr) {
BaizeSetError(baize, strerr);
return 0;
}
return 1;
}