-
Notifications
You must be signed in to change notification settings - Fork 1
/
objects.arc
72 lines (62 loc) · 1.73 KB
/
objects.arc
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
(= objects* (table))
(= users* (table))
(= systems* (table))
(= planets* (table))
(= units* (table))
(= buildings* (table))
(deftem object
id (trunc (* (rand) (expt 10 10)))
type 'object
name nil
parents nil
children nil
owner nil)
(deftem (user object)
pw nil
type 'user
session-id nil
balance 0)
; Systems contain at least one high-mass object that
; other masses orbit (star, singularity, etc)
; Contains a list of references to objects that
; reside in the system
(deftem (system object)
type 'system
name nil ; name of system
location nil ; 3D coordinates
contents nil ; list of residing objects
)
(deftem (planet object)
type 'planet
system nil ; reference to system
planet-type nil ; type of planet
size nil ; size of planet
location nil ; 3D coordinates
residents nil ; list of references to players
buildings nil
) ; that live on the planet (may just be one)
(deftem (unit object)
type 'unit
unit-type nil ; type of unit
location nil ; reference to planet,system,space,etc
health nil ; health of unit
attack nil ; temp placeholder (defines attack value)
armor nil ; temp placeholder (defines armor value)
)
(deftem (building object)
type 'building
location nil
status nil
cost 0)
; Object functions
(def load-objects ()
(each o (git-load-all)
(= (objects* o!id) o)))
(def save-objects ()
(batch-save vals.objects*))
(def restore-tables ()
(maptable (fn (key val)
(if (isnt val!type 'object)
(let x (eval (sym (string val!type 's*)))
(= (x key) val))))
objects*))