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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package main
  2. import (
  3. "fmt"
  4. "math/rand"
  5. // "sort"
  6. // "strings"
  7. "time"
  8. "util"
  9. )
  10. type Character struct {
  11. Name string
  12. TotalForces int
  13. CorporealForces int
  14. EtherealForces int
  15. CelestialForces int
  16. Strength int
  17. Agility int
  18. Intellect int
  19. Precision int
  20. Will int
  21. Perception int
  22. Skills map[string]int
  23. Songs map[string]int
  24. Attunements []string
  25. Distinctions []string
  26. Artifacts []string
  27. Vessels map[string]int
  28. Roles map[string][]int
  29. }
  30. func main() {
  31. rand.Seed(time.Now().UnixNano()) // Keep this first in main()
  32. ply := Character{}
  33. ply.Name = util.Namegen()
  34. ply.TotalForces = 9
  35. ply.CorporealForces = 1
  36. ply.EtherealForces = 1
  37. ply.CelestialForces = 1
  38. ply.Strength = 1
  39. ply.Agility = 1
  40. ply.Intellect = 1
  41. ply.Precision = 1
  42. ply.Will = 1
  43. ply.Perception = 1
  44. i := ply.TotalForces - (ply.CorporealForces + ply.EtherealForces + ply.CelestialForces)
  45. for i > 0 {
  46. r := rand.Intn(3)
  47. if r == 0 {
  48. ply.CorporealForces = ply.CorporealForces + 1
  49. } else if r == 1 {
  50. ply.EtherealForces = ply.EtherealForces + 1
  51. } else {
  52. ply.CelestialForces = ply.CelestialForces + 1
  53. }
  54. i--
  55. }
  56. // Corporeal
  57. coratt := (ply.CorporealForces * 4) - (ply.Strength + ply.Agility)
  58. for coratt > 0 {
  59. r := rand.Intn(2)
  60. if r == 0 {
  61. if ply.Strength == 12 || (ply.Strength >= (ply.Agility*2) && rand.Intn(3) == 0) {
  62. continue
  63. }
  64. ply.Strength = ply.Strength + 1
  65. } else {
  66. if ply.Agility == 12 || (ply.Agility >= (ply.Strength*2) && rand.Intn(3) == 0) {
  67. continue
  68. }
  69. ply.Agility = ply.Agility + 1
  70. }
  71. coratt--
  72. }
  73. // Ethereal
  74. ethatt := (ply.EtherealForces * 4) - (ply.Intellect + ply.Precision)
  75. for ethatt > 0 {
  76. r := rand.Intn(2)
  77. if r == 0 {
  78. if ply.Intellect == 12 || (ply.Intellect >= (ply.Precision*2) && rand.Intn(3) == 0) {
  79. continue
  80. }
  81. ply.Intellect = ply.Intellect + 1
  82. } else {
  83. if ply.Precision == 12 || (ply.Precision >= (ply.Intellect*2) && rand.Intn(3) == 0) {
  84. continue
  85. }
  86. ply.Precision = ply.Precision + 1
  87. }
  88. ethatt--
  89. }
  90. // Corporeal
  91. celatt := (ply.CelestialForces * 4) - (ply.Will + ply.Perception)
  92. for celatt > 0 {
  93. r := rand.Intn(2)
  94. if r == 0 {
  95. if ply.Will == 12 || (ply.Will >= (ply.Perception*2) && rand.Intn(3) == 0) {
  96. continue
  97. }
  98. ply.Will = ply.Will + 1
  99. } else {
  100. if ply.Perception == 12 || (ply.Perception >= (ply.Will*2) && rand.Intn(3) == 0) {
  101. continue
  102. }
  103. ply.Perception = ply.Perception + 1
  104. }
  105. celatt--
  106. }
  107. fmt.Println("=== Generated In Nomine character ===")
  108. fmt.Println(ply.Name)
  109. fmt.Printf("Cor %d\tEth %d\tCel %d\n",
  110. ply.CorporealForces,
  111. ply.EtherealForces,
  112. ply.CelestialForces)
  113. fmt.Printf("Str %d\tInt %d\tCel %d\n",
  114. ply.Strength,
  115. ply.Intellect,
  116. ply.Will)
  117. fmt.Printf("Agi %d\tPre %d\tPer %d\n",
  118. ply.Agility,
  119. ply.Precision,
  120. ply.Perception)
  121. }