model.scm 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. (import
  2. (except (rnrs base) let-values)
  3. (only (guile)
  4. lambda* λ
  5. error
  6. simple-format
  7. current-output-port)
  8. (prefix (logging) log:)
  9. ;; for functional structs (not part of srfi-9 directly)
  10. (srfi srfi-9 gnu)
  11. ;; hash tables
  12. (srfi srfi-69))
  13. (define entity-names
  14. (alist->hash-table
  15. ;; standard chars
  16. '((0 . template)
  17. (1 . deep)
  18. ;; weird gap
  19. (2 . john)
  20. (4 . henry)
  21. (5 . rudolf)
  22. (6 . louis)
  23. (7 . firen)
  24. (8 . freeze)
  25. (9 . dennis)
  26. (10 . woody)
  27. (11 . davis)
  28. ;; stage chars
  29. (30 . bandit)
  30. (31 . hunter)
  31. (32 . mark)
  32. (33 . jack)
  33. (34 . sorcerer)
  34. (35 . monk)
  35. (36 . jan)
  36. (37 . knight)
  37. (39 . justin)
  38. ;; boss chars
  39. (38 . bat)
  40. (50 . louis-ex)
  41. (51 . firzen)
  42. (52 . julian)
  43. ;; randoms
  44. (1000 . 'random-hero)
  45. (3000 . 'random-bandit-hunter)
  46. ;; weapons
  47. (100 . stick)
  48. (101 . pick)
  49. (120 . knife)
  50. (121 . baseball)
  51. (122 . milk)
  52. (150 . stone)
  53. (151 . wooden-box)
  54. (123 . beer)
  55. (124 . boomerang)
  56. (217 . louis-armor-1)
  57. (218 . louis-armor-2)
  58. (300 . criminal))
  59. eqv?))
  60. (define data-ids
  61. (alist->hash-table
  62. ;; standard chars
  63. '((template . 0)
  64. (deep . 1)
  65. ;; weird gap
  66. (john . 2)
  67. (henry . 4)
  68. (rudolf . 5)
  69. (louis . 6)
  70. (firen . 7)
  71. (freeze . 8)
  72. (dennis . 9)
  73. (woody . 10)
  74. (davis . 11)
  75. ;; stage chars
  76. (bandit . 30)
  77. (hunter . 31)
  78. (mark . 32)
  79. (jack . 33)
  80. (sorcerer . 34)
  81. (monk . 35)
  82. (jan . 36)
  83. (knight . 37)
  84. (justin . 39)
  85. ;; boss chars
  86. (bat . 38)
  87. (louis-ex . 50)
  88. (firzen . 51)
  89. (julian . 52)
  90. ;; randoms
  91. ('random-hero . 1000)
  92. ('random-bandit-hunter . 3000)
  93. ;; weapons
  94. (stick . 100)
  95. (pick . 101)
  96. (knife . 120)
  97. (baseball . 121)
  98. (milk . 122)
  99. (stone . 150)
  100. (wooden-box . 151)
  101. (beer . 123)
  102. (boomerang . 124)
  103. (louis-armor-1 . 217)
  104. (louis-armor-2 . 218)
  105. (criminal . 300))
  106. eqv?))
  107. (define data-id->entity-name
  108. (λ (data-id)
  109. (hash-table-ref entity-names
  110. data-id
  111. (λ (id) #f))))
  112. (define entity-name->data-id
  113. (λ (entity-name)
  114. (hash-table-ref data-ids
  115. entity-name
  116. (λ (name) #f))))
  117. (define-immutable-record-type <phase>
  118. ;; define constructor
  119. (make-phase entities
  120. bound
  121. comment
  122. music-switch
  123. go-to-phase)
  124. ;; define predicate
  125. phase?
  126. ;; define accessors and functional setters
  127. (entities phase-entities set-phase-entities)
  128. (bound phase-bound set-phase-bound)
  129. (comment phase-comment set-phase-comment)
  130. (music-switch phase-music-switch set-phase-music-switch)
  131. (go-to-phase phase-go-to-phase set-phase-go-to-phase))
  132. (define-immutable-record-type <entity>
  133. ;; define constructor
  134. (make-entity id
  135. x
  136. y
  137. hp
  138. act
  139. ratio
  140. times
  141. reserve
  142. join
  143. join-reserve
  144. boss
  145. soldier
  146. comment)
  147. ;; define predicate
  148. entity?
  149. ;; define accessors and functional setters
  150. (id entity-id set-entity-id)
  151. (x entity-x set-entity-x)
  152. (y entity-y set-entity-y)
  153. (hp entity-hp set-entity-hp)
  154. (act entity-act set-entity-act)
  155. (ratio entity-ratio set-entity-ratio)
  156. (times entity-times set-entity-times)
  157. (reserve entity-reserve set-entity-reserve)
  158. (join entity-join set-entity-join)
  159. (join-reserve entity-join-reserve set-entity-join-reserve)
  160. (boss entity-boss set-entity-boss)
  161. (soldier entity-soldier set-entity-soldier)
  162. (comment entity-comment set-entity-comment))
  163. (define create-entity
  164. (lambda* (id
  165. hp
  166. #:key
  167. (y #f)
  168. (act #f)
  169. (ratio #f)
  170. (times #f)
  171. (reserve #f)
  172. (join #f)
  173. (join-reserve #f)
  174. (boss #f)
  175. (soldier #f)
  176. (comment #f)
  177. (default-hint? #f))
  178. "Helper procedure for creating entities."
  179. (make-entity
  180. id x y hp act ratio times reserve join join-reserve boss soldier comment)))
  181. (define-immutable-record-type <hint>
  182. ;; define constructor
  183. (make-hint name val)
  184. ;; define predicate
  185. hint?
  186. ;; define accessors and functional setters
  187. (name hint-name set-hint-name)
  188. (val hint-val set-hint-val))