-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.lisp
58 lines (48 loc) · 1.97 KB
/
model.lisp
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
(in-package :strifebarge)
(defclass ship ()
((wid :reader wid :initarg :wid :initform 1)
(len :reader len :initarg :len)
(x :accessor x :initarg :x)
(y :accessor y :initarg :y)
(space-count :accessor space-count :initarg :space-count)
(player :reader player :initarg :player)
(damage :accessor damage :initform 0)
(direction :accessor direction :initarg :direction)))
(define-ship carrier 5 2)
(define-ship cruiser 3)
(define-ship destroyer 2)
(defclass move ()
((player :reader player :initarg :player)
(x :reader x :initarg :x)
(y :reader y :initarg :y)))
(defclass hit (move) ((ship :accessor ship :initarg :ship)))
(defclass miss (move) ())
(defclass history-event ()
((id :reader id :initarg :id)
(event-type :reader event-type :initarg :event-type)
(message :reader message :initarg :message)))
(defclass player ()
((score :accessor score :initform 0)
(sunken :accessor sunken :initarg :sunken)
(ships :accessor ships :initarg :ships)
(turns-missed :accessor turns-missed :initform 0)))
(defclass board-space ()
((x :reader x :initarg :x)
(y :reader y :initarg :y)
(contents :accessor contents :initform nil)
(move :accessor move :initform nil)))
(defclass board ()
((width :reader width :initarg :width)
(height :reader height :initarg :height)
(spaces :accessor spaces :initarg :spaces)))
(defclass game ()
((board :accessor board :initarg :board)
(players :accessor players :initarg :players)
(waiting-for :accessor waiting-for :initarg :waiting-for)
(turn-stack :accessor turn-stack :initarg :turn-stack)
(finished-p :accessor finished-p :initform nil)
(history :accessor history :initform nil)
(turn-count :accessor turn-count :initform 0)
(turn-started :accessor turn-started :initform (now))
(turn-time-limit :accessor turn-time-limit :initarg :turn-time-limit :initform (make-duration :minute 3))
(turns-missed-allowed :accessor turns-missed-allowed :initarg :turns-missed-allowed :initform 3)))