| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  | from datetime import datetime | 
					
						
							|  |  |  | from uuid import UUID, uuid4 | 
					
						
							|  |  |  | from pony.orm import * | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | db = Database() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 01:18:37 +02:00
										 |  |  | STATE_QUEUED = 0 | 
					
						
							|  |  |  | STATE_STARTED = 1 | 
					
						
							|  |  |  | STATE_ERROR = -1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 15:25:57 +02:00
										 |  |  | class Slot(db.Entity): | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  |     id = PrimaryKey(int, auto=True) | 
					
						
							| 
									
										
										
										
											2020-10-26 00:04:58 +01:00
										 |  |  |     player_id = Required(int) | 
					
						
							|  |  |  |     player_name = Required(str, 16) | 
					
						
							| 
									
										
										
										
											2021-05-14 15:25:57 +02:00
										 |  |  |     data = Optional(bytes, lazy=True) | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     seed = Optional('Seed') | 
					
						
							| 
									
										
										
										
											2021-05-14 15:25:57 +02:00
										 |  |  |     game = Required(str) | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Room(db.Entity): | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     id = PrimaryKey(UUID, default=uuid4) | 
					
						
							| 
									
										
										
										
											2020-06-24 08:52:02 +02:00
										 |  |  |     last_activity = Required(datetime, default=lambda: datetime.utcnow(), index=True) | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     creation_time = Required(datetime, default=lambda: datetime.utcnow()) | 
					
						
							| 
									
										
										
										
											2020-06-24 08:52:02 +02:00
										 |  |  |     owner = Required(UUID, index=True) | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  |     commands = Set('Command') | 
					
						
							| 
									
										
										
										
											2020-06-24 08:52:02 +02:00
										 |  |  |     seed = Required('Seed', index=True) | 
					
						
							| 
									
										
										
										
											2020-10-26 00:04:58 +01:00
										 |  |  |     multisave = Optional(buffer, lazy=True) | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     show_spoiler = Required(int, default=0)  # 0 -> never, 1 -> after completion, -> 2 always | 
					
						
							| 
									
										
										
										
											2020-07-10 17:42:22 +02:00
										 |  |  |     timeout = Required(int, default=lambda: 6 * 60 * 60)  # seconds since last activity to shutdown | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     tracker = Optional(UUID, index=True) | 
					
						
							| 
									
										
										
										
											2020-06-21 15:32:31 +02:00
										 |  |  |     last_port = Optional(int, default=lambda: 0) | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Seed(db.Entity): | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     id = PrimaryKey(UUID, default=uuid4) | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  |     rooms = Set(Room) | 
					
						
							| 
									
										
										
										
											2020-10-26 00:04:58 +01:00
										 |  |  |     multidata = Required(bytes, lazy=True) | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     owner = Required(UUID, index=True) | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  |     creation_time = Required(datetime, default=lambda: datetime.utcnow()) | 
					
						
							| 
									
										
										
										
											2021-05-14 15:25:57 +02:00
										 |  |  |     slots = Set(Slot) | 
					
						
							| 
									
										
										
										
											2020-08-03 04:19:36 +02:00
										 |  |  |     spoiler = Optional(LongStr, lazy=True) | 
					
						
							| 
									
										
										
										
											2021-11-16 23:59:40 +01:00
										 |  |  |     meta = Required(LongStr, default=lambda: "{\"race\": false}")  # additional meta information/tags | 
					
						
							| 
									
										
										
										
											2020-06-20 20:03:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Command(db.Entity): | 
					
						
							|  |  |  |     id = PrimaryKey(int, auto=True) | 
					
						
							|  |  |  |     room = Required(Room) | 
					
						
							|  |  |  |     commandtext = Required(str) | 
					
						
							| 
									
										
										
										
											2020-08-18 01:18:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Generation(db.Entity): | 
					
						
							|  |  |  |     id = PrimaryKey(UUID, default=uuid4) | 
					
						
							|  |  |  |     owner = Required(UUID) | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |     options = Required(buffer, lazy=True) | 
					
						
							| 
									
										
										
										
											2021-11-16 23:59:40 +01:00
										 |  |  |     meta = Required(LongStr, default=lambda: "{\"race\": false}") | 
					
						
							| 
									
										
										
										
											2020-08-18 01:18:37 +02:00
										 |  |  |     state = Required(int, default=0, index=True) |