-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbmodel.sql
69 lines (60 loc) · 2.16 KB
/
dbmodel.sql
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
-- ------
-- BGA framework: © Gregory Isabelli <[email protected]> & Emmanuel Colin <[email protected]>
-- MagicMaze implementation : © <Your name here> <Your email address here
--
-- This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
-- See http://en.boardgamearena.com/#!doc/Studio for more information.
-- -----
create table `tiles` (
`tile_id` int unsigned not null,
`placed` bool not null default false,
`tile_order` int not null,
`position_x` int,
`position_y` int,
`rotation` int,
primary key (`tile_id`)
) ENGINE=InnoDB;
create function find_tile(x int, y int) returns int begin
return (select tile_id from tiles where
x - position_x between 0 and 3
and y - position_y between 0 and 3);
end;
-- The token that initiates an explore half-step is locked.
-- This stops people from invalidly moving a meeple when the person is
-- trying to decide where to put the tile(s). This is much cleaner for
-- all sorts of races (including if the timer is flipped when the person
-- is looking at tiles).
-- `dummy` is used for a half-step to reduce the number of db roundtrips.
-- You can remove it when the feature request
-- https://forum.boardgamearena.com/viewtopic.php?f=12&t=15723
-- is resolved.
create table `tokens` (
`token_id` int unsigned not null,
`position_x` int not null,
`position_y` int not null,
`locked` bool not null default false,
`dummy` bool not null default false,
primary key (`token_id`)
) ENGINE=InnoDB;
create table `walls` (
`old_x` int not null,
`old_y` int not null,
`new_x` int not null,
`new_y` int not null,
`dwarf` bool not null default false,
primary key (`old_x`, `old_y`, `new_x`, `new_y`)
) ENGINE=InnoDB;
create table `escalators` (
`old_x` int not null,
`old_y` int not null,
`new_x` int not null,
`new_y` int not null,
primary key (`old_x`, `old_y`, `new_x`, `new_y`)
) ENGINE=InnoDB;
create table `properties` (
`position_x` int not null,
`position_y` int not null,
`token_id` int,
`property` varchar(32) not null,
primary key (`position_x`, `position_y`)
) ENGINE=InnoDB;