You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. package main
  2. import (
  3. "fmt"
  4. "math/rand"
  5. "sort"
  6. "strconv"
  7. "strings"
  8. "time"
  9. "util"
  10. )
  11. type Character struct {
  12. Name string
  13. TotalForces int
  14. CorporealForces int
  15. EtherealForces int
  16. CelestialForces int
  17. Strength int
  18. Agility int
  19. Intellect int
  20. Precision int
  21. Will int
  22. Perception int
  23. Skills map[string]int
  24. Songs map[string]int
  25. Attunements []string
  26. Distinctions []string
  27. Artifacts []string
  28. Vessels map[string]int
  29. Roles map[string][]int
  30. }
  31. func main() {
  32. rand.Seed(time.Now().UnixNano()) // Keep this first in main()
  33. ply := Character{}
  34. ply.Name = util.Namegen()
  35. ply.TotalForces = 9
  36. ply.CorporealForces = 1
  37. ply.EtherealForces = 1
  38. ply.CelestialForces = 1
  39. ply.Strength = 1
  40. ply.Agility = 1
  41. ply.Intellect = 1
  42. ply.Precision = 1
  43. ply.Will = 1
  44. ply.Perception = 1
  45. ply.Skills = make(map[string]int)
  46. ply.Songs = make(map[string]int)
  47. corSkills := make([]string, 0, 50)
  48. ethSkills := make([]string, 0, 50)
  49. celSkills := make([]string, 0, 50)
  50. akList := make([]string, 0, 50)
  51. knowList := make([]string, 0, 50)
  52. langList := make([]string, 0, 50)
  53. songList := make([]string, 0, 50)
  54. for _, v := range []string{"Acrobatics", "Climbing", "Dodge", "Escape", "Fighting", "Large Weapon", "Move Silently", "Running", "Swimming", "Throwing"} {
  55. corSkills = append(corSkills, v)
  56. }
  57. for _, v := range []string{"Knowledge", "Knowledge", "Knowledge", "Area Knowledge", "Area Knowledge", "Area Knowledge", "Chemistry", "Computer Operation", "Driving", "Electronics", "Engineering", "Language", "Lockpicking", "Lying", "Medicine", "Ranged Weapon", "Savoir-Faire", "Small Weapon", "Tactics"} {
  58. ethSkills = append(ethSkills, v)
  59. }
  60. for _, v := range []string{"Artistry", "Detect Lies", "Emote", "Fast-Talk", "Seduction", "Singing", "Survival", "Tracking"} {
  61. celSkills = append(celSkills, v)
  62. }
  63. for _, v := range []string{"Heaven", "Hell", "Marches", "Caribbean", "New York", "New England", "Florida", "Atlanta", "Texas", "California", "American Southwest", "Pacific Northwest", "Portland", "Toronto", "Vancouver", "Mexico", "Central America", "Brazil", "Argentina", "England", "London", "France", "Paris", "Norway", "Scandinavia", "Greece", "Egypt", "North Africa", "Sub-Saharan Africa", "Saudi Arabia", "Middle East", "Russia", "Moscow", "China", "Shanghai", "Hong Kong", "Japan", "Hokkaido", "Tokyo", "Australia", "Sydney", "Melbourne", "Perth", "Fiji", "Antarctica"} {
  64. akList = append(akList, v)
  65. }
  66. for _, v := range []string{"Astronomy", "Biology", "Literature", "Aircraft", "American Football", "Football", "Baseball", "Sumo", "Giant Robot Anime", "German Cuisine", "Catholicism", "Islam", "Buddhism", "Shinto", "Architecture", "Eschatology", "Numinology", "Role-Playing Games", "Spelunking", "Parliamentary Procedure", "Olympic History", "18th-Century Botanical Manuals", "Photography", "Marine Biology", "Entomology", "Archaeology"} {
  67. knowList = append(knowList, v)
  68. }
  69. for _, v := range []string{"Mandarin", "Spanish", "English", "Hindi", "Arabic", "Portuguese", "Bengali", "Russian", "Japanese", "Punjabi", "German", "Javanese", "Wu", "Malay", "Telugu", "Vietnamese", "Korean", "French", "Marathi", "Tamil", "Urdu", "Turkish", "Italian", "Yue (Cantonese)", "Thai", "Latin", "Greek", "Ancient Egyptian", "Apache", "Ainu", "Aleut", "Inuit", "Mayan"} {
  70. langList = append(langList, v)
  71. }
  72. for _, v := range []string{"Attraction", "Charm", "Dreams", "Entropy", "Form", "Harmony", "Healing", "Motion", "Numinous Corpus", "Possession", "Projection", "Shields", "Thunder", "Tongues"} {
  73. songList = append(songList, v)
  74. }
  75. i := ply.TotalForces - (ply.CorporealForces + ply.EtherealForces + ply.CelestialForces)
  76. for i > 0 {
  77. r := rand.Intn(3)
  78. if r == 0 {
  79. ply.CorporealForces = ply.CorporealForces + 1
  80. } else if r == 1 {
  81. ply.EtherealForces = ply.EtherealForces + 1
  82. } else {
  83. ply.CelestialForces = ply.CelestialForces + 1
  84. }
  85. i--
  86. }
  87. cp, corBrk, ethBrk := ply.TotalForces*4, ply.CorporealForces, ply.CorporealForces+ply.EtherealForces
  88. sklBrk := 12
  89. // Corporeal
  90. coratt := (ply.CorporealForces * 4) - (ply.Strength + ply.Agility)
  91. for coratt > 0 {
  92. r := rand.Intn(2)
  93. if r == 0 {
  94. if ply.Strength == 12 || (ply.Strength >= (ply.Agility*2) && rand.Intn(3) == 0) {
  95. continue
  96. }
  97. ply.Strength = ply.Strength + 1
  98. } else {
  99. if ply.Agility == 12 || (ply.Agility >= (ply.Strength*2) && rand.Intn(3) == 0) {
  100. continue
  101. }
  102. ply.Agility = ply.Agility + 1
  103. }
  104. coratt--
  105. }
  106. // Ethereal
  107. ethatt := (ply.EtherealForces * 4) - (ply.Intellect + ply.Precision)
  108. for ethatt > 0 {
  109. r := rand.Intn(2)
  110. if r == 0 {
  111. if ply.Intellect == 12 || (ply.Intellect >= (ply.Precision*2) && rand.Intn(3) == 0) {
  112. continue
  113. }
  114. ply.Intellect = ply.Intellect + 1
  115. } else {
  116. if ply.Precision == 12 || (ply.Precision >= (ply.Intellect*2) && rand.Intn(3) == 0) {
  117. continue
  118. }
  119. ply.Precision = ply.Precision + 1
  120. }
  121. ethatt--
  122. }
  123. // Celestial
  124. celatt := (ply.CelestialForces * 4) - (ply.Will + ply.Perception)
  125. for celatt > 0 {
  126. r := rand.Intn(2)
  127. if r == 0 {
  128. if ply.Will == 12 || (ply.Will >= (ply.Perception*2) && rand.Intn(3) == 0) {
  129. continue
  130. }
  131. ply.Will = ply.Will + 1
  132. } else {
  133. if ply.Perception == 12 || (ply.Perception >= (ply.Will*2) && rand.Intn(3) == 0) {
  134. continue
  135. }
  136. ply.Perception = ply.Perception + 1
  137. }
  138. celatt--
  139. }
  140. b := 7 + rand.Intn(6)
  141. for i := cp; i > b; i-- {
  142. r := rand.Intn(15)
  143. if r < sklBrk { // it's a skill
  144. if rand.Intn(3) == 0 && len(ply.Skills) != 0 {
  145. key, val := util.ChoiceMap(ply.Skills)
  146. ply.Skills[key] = val + 1
  147. } else {
  148. q := rand.Intn(ply.TotalForces)
  149. skl := ""
  150. if q < corBrk { // it's a corporeal skill
  151. skl = util.ChoiceStr(corSkills)
  152. // fmt.Println("Selected Corporeal skill: ", skl)
  153. } else if q < ethBrk { // it's an ethereal skill
  154. skl = util.ChoiceStr(ethSkills)
  155. if skl == "Knowledge" {
  156. subskl := util.ChoiceStr(knowList)
  157. skl = "Knowledge (" + subskl + ")"
  158. } else if skl == "Area Knowledge" {
  159. subskl := util.ChoiceStr(akList)
  160. skl = "Area Knowledge (" + subskl + ")"
  161. } else if skl == "Language" {
  162. subskl := util.ChoiceStr(langList)
  163. skl = "Language (" + subskl + ")"
  164. }
  165. // fmt.Println("Selected Ethereal skill: ", skl)
  166. } else { // it's a celestial skill
  167. skl = util.ChoiceStr(celSkills)
  168. // fmt.Println("Selected Celestial skill: ", skl)
  169. }
  170. ply.Skills[skl] = ply.Skills[skl] + 1
  171. }
  172. } else { // Songs
  173. if rand.Intn(3) == 0 && len(ply.Songs) != 0 {
  174. key, val := util.ChoiceMap(ply.Songs)
  175. ply.Songs[key] = val + 1
  176. } else {
  177. skl := util.ChoiceStr(songList)
  178. // fmt.Println("Selected song: ", skl)
  179. ply.Songs[skl] = ply.Songs[skl] + 1
  180. }
  181. }
  182. }
  183. skills := make([]string, 0, len(ply.Skills))
  184. songs := make([]string, 0, len(ply.Songs))
  185. // fmt.Println(len(ply.Skills), len(ply.Songs), ply.Skills, ply.Songs)
  186. for k, v := range ply.Skills {
  187. skills = append(skills, k+"/"+strconv.Itoa(v))
  188. }
  189. for k, v := range ply.Songs {
  190. songs = append(songs, k+"/"+strconv.Itoa(v))
  191. }
  192. sort.Strings(skills)
  193. sort.Strings(songs)
  194. sklout := strings.Join(skills[:], ", ")
  195. sngout := strings.Join(songs[:], ", ")
  196. fmt.Println("=== Generated In Nomine character ===")
  197. fmt.Println(ply.Name)
  198. fmt.Printf("Cor %d\tEth %d\tCel %d\n",
  199. ply.CorporealForces,
  200. ply.EtherealForces,
  201. ply.CelestialForces)
  202. fmt.Printf("Str %d\tInt %d\tCel %d\n",
  203. ply.Strength,
  204. ply.Intellect,
  205. ply.Will)
  206. fmt.Printf("Agi %d\tPre %d\tPer %d\n",
  207. ply.Agility,
  208. ply.Precision,
  209. ply.Perception)
  210. fmt.Println("Skills: ", sklout)
  211. fmt.Println("Songs: ", sngout)
  212. fmt.Println("CP Remaining: ", b)
  213. }