forked from mkm3110/CornellSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameDataStructure.ml
More file actions
118 lines (92 loc) · 2.86 KB
/
Copy pathgameDataStructure.ml
File metadata and controls
118 lines (92 loc) · 2.86 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
open GameGaugesDict
(** [String] provides the necessary definitions to use strings as keys in
GameGaugesDict *)
module String : KeyType with type t = string = struct
type t = string
let compare s1 s2 = Stdlib.compare s1 s2
end
(** [CaselessString] provides the necessary definitions to use strings as keys in
GameGaugesDict *)
module CaselessString : KeyType with type t = string = struct
type t = string
let compare s1 s2 =
Stdlib.compare
(Stdlib.String.lowercase_ascii s1)
(Stdlib.String.lowercase_ascii s2)
end
(** [IntPos] provides the necessary definitions to use int as keys in
GameGaugesDict *)
module IntPos = struct
exception IllegalSubtraction
type t = int
let to_string t = string_of_int t
let compare x y = Stdlib.compare x y
let format fmt x = Format.fprintf fmt "%d" x
let add i1 i2 = i1 + i2
let divide i1 i2 = Float.of_int i1 /. Float.of_int i2
let minimum = 0
let defualt = 20
let subtract i1 i2 =
let num = i1 - i2 in
if num < minimum then raise IllegalSubtraction else num
end
(** [GaugesValue] provides a type to represent necessary information for gauges value in the map *)
module type GaugesValue = sig
type t = {
value : int;
max : int;
color : Graphics.color;
}
include GameVal with type t := t
end
module GaugesValue : GaugesValue = struct
type t = {
value : int;
max : int;
color : Graphics.color;
}
end
(** [ItemTypeInfo] provides a type to represent necessary information for item type value of the map *)
module type ItemTypeInfo = sig
type t = {
name : string;
description : string;
image : Graphics.image;
effect : Effect.t;
dmax : int;
}
include GameVal with type t := t
end
(** [ItemInventory] provides a type to represent necessary information for item inventory value of the map *)
module type ItemInventory = sig
type t = {
value : int;
max : int;
item_type : string;
}
include GameVal with type t := t
end
module ItemInventory : ItemInventory = struct
type t = {
value : int;
max : int;
item_type : string;
}
end
module ItemTypeInfo : ItemTypeInfo = struct
type t = {
name : string;
description : string;
image : Graphics.image;
effect : Effect.t;
dmax : int;
}
end
(** [GameIntDict] is a data structure for maintaining gauges information *)
module GameIntDict = MakeGameDict (GaugesValue) (CaselessString)
(** [ItemTypeDict] is a data structure for maintaining item type information *)
module ItemTypeDict = MakeGameDict (ItemTypeInfo) (CaselessString)
(** [InventoryDict] is a data structure for maintaining inventory information *)
module InventoryDict = MakeGameDict (ItemInventory) (CaselessString)
(** [ClassMapping] is a data structure for maintaining the information on the mapping between gauge id and display name *)
module ClassMapping = MakeGameDict (String) (String)