Advertisement
Guest User

Untitled

a guest
May 20th, 2017
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Contains the flattened Player Class and its related subclasses from
  2. # Character, Attributes, and so forth. This will make for a large file but
  3. # I would rather get something build-ready and then try to address this with
  4. # Inheritance later.
  5.  
  6. extends Node
  7.  
  8. # TODO Import the Dice Objects
  9.  
  10. # Character defining attributes
  11. # Origin Character.gd
  12. var CharacterName = ""
  13. var CharacterLevel = 0
  14. var CharacterExperiencePoints = 0
  15. var HitPoints = 0
  16. var MaxHitPoints = 0
  17. var AbilityPoints = 0
  18. var MaxAbilityPoints = 0
  19. var Potential = 0
  20. var RecoveredHitPoints = 0
  21. var RecoveredAbilityPoints = 0
  22.  
  23. # Origin Attributes.gd
  24. # Primary Attributes
  25. var PAConstitution = 0
  26. var PAStrength = 0
  27. var PAIntelligence = 0
  28. var PAPerception = 0
  29. var PAProvidence = 0
  30.  
  31. # Derived Statistics
  32. var DSMaxHitPoints = 0
  33. var DSMaxAbilityPoints = 0
  34. var DSAttackPower = 0
  35. var DSDefensePower = 0
  36. var DSAbilityPower = 0
  37. var DSAgility = 0
  38. var DSAbilityAwareness = 0
  39. var DSCriticalDamage = 0
  40. var DSInventoryCapacity = 0
  41. var DSCurrentInventoryUsage = 0
  42. var DSCombatAwareness = 0
  43. var DSCriticalThinking = 0
  44. var DSEconomics = 0
  45. var DSTechnicalProf = 0
  46. var DSCommunication = 0
  47. var DSEffectRes = 0
  48. var DSStamina = 0
  49. var DSFabrication = 0
  50.  
  51. # TODO Make sure we need these (adding to compile)
  52. var StatusAbilityPoints
  53. var Strength
  54. var CalcAtkPts
  55. var DefPwrMax
  56. var AblPwrDelta
  57. var MaxStrVal
  58. var NewInvUsage
  59. var CraftingRandomAdd
  60. var RecoveredHitPoints
  61.  
  62. # Constants
  63. const MAX_LEVEL = 25
  64. const INVENTORY_MULTI = 7
  65. const D20_MIN = 1
  66. const D20_MAX = 20
  67.  
  68. # Methods
  69.  
  70. # Origin Character.gd
  71. func SetGameStartAttributes():
  72. """
  73. Set up initial attributes for the character (stubbed function)
  74. """
  75. # TODO
  76. pass
  77.  
  78. func SetPlayerName(name):
  79. """
  80. Set player name. If a value that is not a string, or an empty string is set,
  81. the method returns false.
  82.  
  83. Keyword arguments:
  84. name -- The name of the character in a String form. (Required)
  85. """
  86. if typeof(name) != TYPE_STRING:
  87. return false
  88.  
  89. if name.empty() == true:
  90. return false
  91.  
  92. CharacterName = name
  93. return CharacterName
  94.  
  95. func GetPlayerName():
  96. """
  97. Returns player name.
  98. """
  99. return CharacterName
  100.  
  101. func SetPrimaryStats(Const, Str, Int, Per, Prov):
  102. """
  103. Set the player primary stats. All primary stats must be defined as
  104. non negative integers, or else the method will return false. They can be
  105. defined as zero.
  106.  
  107. Keyword arguments:
  108. Const -- Representation of Constitution (Required)
  109. Str -- Representation of Strength (Required)
  110. Int -- Representation of Intelligence (Required)
  111. Per -- Representation of Perception (Required)
  112. Prov -- Representation of Providence (Required)
  113. """
  114. if typeof(Const) != TYPE_INT \
  115. and typeof(Str) != TYPE_INT \
  116. and typeof(Int) != TYPE_INT \
  117. and typeof(Per) != TYPE_INT \
  118. and typeof(Prov) != TYPE_INT:
  119. return false
  120.  
  121. if Const >= 0 \
  122. and Str >= 0 \
  123. and Int >= 0 \
  124. and Per >= 0 \
  125. and Prov >= 0:
  126. return false
  127.  
  128. set_constitution(Const)
  129. set_strength(Str)
  130. set_intelligence(Int)
  131. set_perception(Per)
  132. set_providence(Prov)
  133. return true
  134.  
  135. func SetNonStatusDerivedStats():
  136. """
  137. Sets all the derived statistics not HP or Ability Points
  138. """
  139. # TODO
  140.  
  141. func SetHitPoints():
  142. """
  143. Set the initial Hit Points on creation
  144. """
  145. self.HitPoints = (get_constitution() * 15) + floor((1.5 * get_strength()))
  146. self.MaxHitPoints = HitPoints
  147. return self.HitPoints
  148.  
  149. func AddHitPoints(delta):
  150. """
  151. Add hit points passed through as a delta. This operation is
  152. intended to be used when Healing or Recovery operations are being used
  153. by the player.
  154.  
  155. If the delta is not defined, or is a negative integer the
  156. argument returns false.
  157.  
  158. If the delta leads the new total to exceed the maximum Hit Points
  159. possible, then return the Maximum Hit Points.
  160.  
  161. Keyword arguments:
  162. delta -- An integer representing Hit Points to be added to the
  163. character (Required)
  164. """
  165.  
  166. if typeof(delta) == TYPE_INT and delta > -1:
  167. RecoveredHitPoints = HitPoints + delta
  168. if RecoveredHitPoints >= MaxHitPoints:
  169. HitPoints = MaxHitPoints
  170. return HitPoints
  171. else:
  172. HitPoints = RecoveredHitPoints
  173. return HitPoints
  174. else:
  175. return false
  176.  
  177. func IncreaseHitPoints(delta):
  178. """
  179. Add hit points passed through as a delta. This operation is
  180. intended to be used when Leveling Up, or other stat-boosting
  181. operations are being used by the player or the character. Any math that
  182. must be run to calculate what the Delta is obviously needs to be done
  183. before you run this method.
  184.  
  185. If the delta is not defined, the argument returns false.
  186.  
  187. Keyword arguments:
  188. delta -- An integer representing Hit Points to be added to the
  189. character. (Required)
  190. """
  191. if typeof(delta) == TYPE_INT and delta >= 0:
  192. MaxHitPoints = MaxHitPoints + delta;
  193. HitPoints = MaxHitPoints
  194. return HitPoints
  195. else:
  196. return false
  197.  
  198. func RemoveHitPoints(delta):
  199. """
  200. Remove hit points passed through as a delta.
  201.  
  202. If delta is not defined, the argument returns false, changing nothing.
  203.  
  204. Keyword arguments:
  205. delta -- An integer representing Hit Points to be removed from the
  206. character. (Required)
  207. """
  208. if typeof(delta) == TYPE_INT and delta >= 0:
  209. HitPoints = HitPoints - delta
  210. else:
  211. return false
  212.  
  213. func GetCurrentHitPoints():
  214. """
  215. Returns the current Hit Points for the Character
  216. """
  217. return HitPoints
  218.  
  219. func GetMaxHitPoints():
  220. """
  221. Returns the maximum number of Hit Points
  222. """
  223. return MaxHitPoints
  224.  
  225. func SetAbilityPoints():
  226. """
  227. Set the initial Ability Points on creation
  228. """
  229. AbilityPoints = (4 * get_intelligence()) + floor((1.5 * get_perception()))
  230. MaxAbilityPoints = AbilityPoints
  231. return AbilityPoints
  232.  
  233. func AddAbilityPoints(delta):
  234. """
  235. Add ability points passed through as a delta. This operations is
  236. intended to be used when Recovery operations are being used by the
  237. player.
  238.  
  239. If the delta is not defined, the argument returns false.
  240.  
  241. If the delta leads the new total to exceed the maximum Ability Points
  242. possible, then return the Maximum Ability Points.
  243.  
  244. Keyword arguments:
  245. delta -- An integer representing Ability Points to be added to the
  246. character (Required)
  247. """
  248. if typeof(delta) == TYPE_INT and delta >= 0:
  249. RecoveredAbilityPoints = AbilityPoints + delta
  250. if RecoveredAbilityPoints >= MaxAbilityPoints:
  251. AbilityPoints = MaxAbilityPoints
  252. return AbilityPoints
  253. else:
  254. AbilityPoints = RecoveredAbilityPoints
  255. return HitPoints
  256. else:
  257. return false
  258.  
  259. func IncreaseAbilityPoints(delta):
  260. """
  261. Add ability points passed through as a delta. This operation is
  262. intended to be used when Leveling Up, or other stat-boosting
  263. operations are being used by the player or the character. Any math that
  264. must be run to calculate what the Delta is obviously needs to be done
  265. before you run this method.
  266.  
  267. If the delta is not defined, the argument returns false.
  268.  
  269. Keyword arguments:
  270. delta -- An integer representing Ability Points to be added to the
  271. character. (Required)
  272. """
  273. if typeof(delta) == TYPE_INT and delta >= 0:
  274. MaxAbilityPoints = MaxAbilityPoints + delta;
  275. AbilityPoints = MaxAbilityPoints
  276. return AbilityPoints
  277. else:
  278. return false
  279.  
  280. func RemoveAbilityPoints(delta):
  281. """
  282. Remove ability points passed through as a delta. If delta is not
  283. defined, the argument returns false, changing nothing.
  284.  
  285. Keyword arguments:
  286. delta -- An integer representing Ability Points to be removed
  287. from the character. (Required)
  288. """
  289. if typeof(delta) == TYPE_INT and delta >= 0:
  290. AbilityPoints = AbilityPoints - delta;
  291. return AbilityPoints;
  292. else:
  293. return false
  294.  
  295. func GetCurrentAbilityPoints():
  296. """
  297. Returns the current total of Ability Points for the Character
  298. """
  299. return AbilityPoints
  300.  
  301. func ReturnMaxAbilityPoints():
  302. """
  303. Returns the Maximum available Ability Points
  304. """
  305. return MaxAbilityPoints
  306.  
  307. func SetInitialCharacterLevel():
  308. """
  309. Sets Character Level to 1
  310. """
  311. CharacterLevel = 1
  312. return CharacterLevel
  313.  
  314. func IncreaseCharacterLevel():
  315. """
  316. Increments the Character Level by 1, unless it hits its potential max, 25.
  317. """
  318. if CharacterLevel != MAX_LEVEL:
  319. CharacterLevel = CharacterLevel + 1;
  320. return CharacterLevel
  321.  
  322. func SetCharacterPotential():
  323. """
  324. Calculates the Character's Potential. This operation is run when new
  325. equipment is attached, a level is gained, and so forth.
  326. """
  327. #TODO last method once the rest are in place.
  328.  
  329. func SetExperiencePoints():
  330. """
  331. Sets Experience Points to 0, to start out with.
  332. """
  333. CharacterExperiencePoints = 0;
  334.  
  335. func AddExperiencePoints(delta):
  336. """
  337. Add experience points passed through as a delta. If delta is
  338. not defined, the argument returns false, changing nothing.
  339.  
  340. Keyword arguments:
  341. delta -- An integer representing Experience Points to be
  342. added to the character. (Required)
  343. """
  344. if typeof(delta) == TYPE_INT and delta >= 0:
  345. CharacterExperiencePoints = CharacterExperiencePoints + delta;
  346. return CharacterExperiencePoints;
  347. else:
  348. return false
  349.  
  350. # Origin Attributes.gd
  351. # ----
  352. # Primary Statistics Setting/Retrieval Methods
  353. # ----
  354.  
  355. func set_constitution(con):
  356. """
  357. Sets the points allocated to Constitution. If not an integer, or is set
  358. to zero, return false.
  359.  
  360. Keyword arguments:
  361. con -- Integer value for Constitution. (Required)
  362. """
  363. if typeof(con) == TYPE_INT:
  364. if con > 0:
  365. PAConstitution = con
  366. return PAConstitution;
  367. else:
  368. return false
  369. else:
  370. return false
  371.  
  372. func get_constitution():
  373. """
  374. Returns the number of points set to Constitution
  375. """
  376. return PAConstitution
  377.  
  378. func set_strength(srn):
  379. """
  380. Sets the points allocated to Strength. If not an integer, or is set to
  381. zero, return false.
  382.  
  383. Keyword arguments:
  384. srn -- Integer value for Strength (Required)
  385. """
  386. if typeof(srn) == TYPE_INT:
  387. if srn > 0:
  388. PAStrength = srn
  389. return PAStrength
  390. else:
  391. return false
  392. else:
  393. return false
  394.  
  395. func get_strength():
  396. """
  397. Returns the number of points set to Strength
  398. """
  399. return PAStrength
  400.  
  401. func set_intelligence(nti):
  402. """
  403. Sets the points allocated to Intelligence. If not an integer, or is
  404. set to zero, return false.
  405.  
  406. Keyword arguments:
  407. nti -- Integer value for Intelligence (Required)
  408. """
  409. if typeof(nti) == TYPE_INT:
  410. if nti > 0:
  411. PAIntelligence = nti
  412. return PAIntelligence
  413. else:
  414. return false
  415. else:
  416. return false
  417.  
  418. func get_intelligence():
  419. """
  420. Returns the points allocated to Intelligence
  421. """
  422. return PAIntelligence
  423.  
  424. func set_perception(per):
  425. """
  426. Sets the points allocated to Perception. If not an integer, or is set
  427. to zero, return false.
  428.  
  429. Keyword arguments:
  430. per -- Integer value for Perception (Required)
  431. """
  432. if typeof(per) == TYPE_INT:
  433. if per > 0:
  434. PAPerception = per
  435. return PAPerception
  436. else:
  437. return false
  438. else:
  439. return false
  440.  
  441. func get_perception():
  442. """
  443. Returns the points allocated to Perception
  444. """
  445. return PAPerception
  446.  
  447. func set_providence(pro):
  448. """
  449. Sets the points allocated to Providence. If not an integer, or is set
  450. to zero, return false.
  451.  
  452. Keyword arguments:
  453. pro -- Integer value for Providence (Required)
  454. """
  455. if typeof(pro) == TYPE_INT:
  456. if pro > 0:
  457. PAProvidence = pro
  458. return PAProvidence
  459. else:
  460. return false
  461. else:
  462. return false
  463.  
  464. func get_providence():
  465. """
  466. Returns the points allocated to Providence
  467. """
  468. return PAProvidence
  469.  
  470. # ----
  471. # Derived Statistics Modifying Methods
  472. # ----
  473.  
  474. # Hit Points
  475. func set_hit_points_creation(Con, Srn):
  476. """
  477. Assign initial hit points on character creation.
  478. """
  479. var HP = (Con * 15) + floor((1.5 * Srn))
  480. return HP
  481.  
  482. func set_hit_points_levelup(Con):
  483. """
  484. TODO: Marked for removal (I think)
  485. Append additional Hit Points on character Level Up
  486. """
  487. var HP = DSMaxHitPoints + (((randi()%6+1) / 2) + 5)
  488. return HP
  489.  
  490. # Ability Points
  491. func set_ability_points_creation(Int, Per):
  492. """
  493. Assign Ability Points on Player Creation.
  494. """
  495. DSMaxAbilityPoints = (4 * Int) + floor((1.5 * Per))
  496. StatusAbilityPoints = DSMaxAbilityPoints
  497.  
  498. func set_ability_points_levelup(Int):
  499. """
  500. Append additional ability points on character Level Up.
  501. TODO Marked for Removal (or Refactor into Character.gd)
  502. """
  503. DSMaxAbilityPoints = DSMaxAbilityPoints + (Int * (randi()%6+1))
  504. StatusAbilityPoints = DSMaxAbilityPoints
  505.  
  506. func get_current_ability_points():
  507. """
  508. TODO Remove (Moved to Character.gd)
  509. """
  510. return StatusAbilityPoints
  511.  
  512. func get_max_ability_points():
  513. """
  514. TODO Remove (Moved to Character.gd)
  515. """
  516. return DSMaxAbilityPoints
  517.  
  518. # Attack Power
  519. func set_attack_power_creation(Str):
  520. """
  521. Sets the Attack Power for the Character during the creation phase.
  522. The Strength attribute is required for this to execute. If not
  523. an integer or is zero, returns false.
  524.  
  525. Keyword arguments:
  526. Str -- Integer representation of strength. (Required)
  527. """
  528. if typeof(Str) == TYPE_INT:
  529. if Str > 0:
  530. DSAttackPower = floor(Strength * 2.5)
  531. return DSAttackPower
  532. else:
  533. return false
  534. else:
  535. return false
  536.  
  537. func set_attack_power_levelup(AtkPts = null):
  538. """
  539. Increases the attack points in place for the Character based on the
  540. formula in the docs. If AtkPts is not set, it attempts to pull it
  541. from the Object attribute. If either the Argument or Object attribute
  542. are zero or not an integer, the method retuns false.
  543.  
  544. Keyword arguments:
  545. AtkPts -- Integer representation of Attack Points. Defaults to Nil.
  546. """
  547. var RandIncrementDie = DiceObj.new()
  548. # var Results = BirthModifierDie.roll_the_dice(3, 20);
  549.  
  550. if typeof(AtkPts) == TYPE_NIL:
  551. CalcAtkPts = DSAttackPower
  552. elif typeof(AtkPts) == TYPE_INT:
  553. if AtkPts > 0:
  554. CalcAtkPts = AtkPts
  555. DSAttackPower = CalcAtkPts + (.5 * floor(RandIncrementDie.roll_the_dice(D20_MIN, D20_MAX)))
  556. return DSAttackPower
  557. else:
  558. return false
  559. else:
  560. return false
  561.  
  562. func get_attack_power():
  563. """
  564. Returns the attack power for the assigned Character.
  565. """
  566. return DSAttackPower
  567.  
  568. # Defense Power
  569. func set_defense_power_creation(Str, Con):
  570. """
  571. Sets the Defense Power on Character Creation. The Strength and
  572. Constitutions attributes are required to set this attribute. If not an
  573. integer, or not greater than zero, the method returns false.
  574.  
  575. Keyword attributes:
  576. Str -- Integer representation of strength. (Required).
  577. Con -- Integer representation of Constitution (Required).
  578. """
  579. if (typeof(Str) == TYPE_INT) and (typeof(Con) == TYPE_INT):
  580. if (Str > 0) && (Con > 0):
  581. DSDefensePower = Con * floor(.5 * Str)
  582. return DSDefensePower
  583. else:
  584. return false
  585. else:
  586. return false
  587.  
  588. func set_defense_power_levelup(Str, ExistingDefPwr):
  589. """
  590. Increases the Defense Power on Character Creation based on the outlined
  591. formulae in the Design Bible. Requires the Strength and Existing Power
  592. be passed as arguments. If they aren't integers, or are zero, the
  593. method returns false.
  594.  
  595. Keyword arguments:
  596. Str -- Integer representation of strength. (Required).
  597. ExistingDefPwr -- Integer representation of Existing Defense Power.
  598. (Required)
  599. """
  600. if (typeof(Str) == TYPE_INT) and (typeof(ExistingDefPwr) == TYPE_INT):
  601. if (Str > 0) and (ExistingDefPwr > 0):
  602. var DefPwrDelta = DiceObj.new()
  603. DefPwrMax = DefPwrDelta.roll_the_dice(1, (Str^2))
  604. DSDefensePower = ExistingDefPwr + floor(DefPwrMax)
  605. return DSDefensePower
  606. else:
  607. return false
  608. else:
  609. return false
  610.  
  611. func get_defense_power():
  612. """
  613. Get the defensive power for the Character
  614. """
  615. return DSDefensePower
  616.  
  617. # Ability Power
  618. func set_ability_power_creation(Int, Pro):
  619. """
  620. Sets the Character's ability power on creation. To do this, the
  621. Intelligence and Providence must be passed as non-zero Integers
  622. or else the method will return false.
  623.  
  624. Keyword arguments:
  625. Int - Integer representation of Intelligence (Required)
  626. Pro - Integer representation of Providence (Required)
  627. """
  628. if (typeof(Int) == TYPE_INT) and (typeof(Pro) == TYPE_INT):
  629. if (Int > 0) and (Pro > 0):
  630. DSAbilityPower = Int + (.5 * floor(Pro * 1.5))
  631. return DSAbilityPower
  632. else:
  633. return false
  634. else:
  635. return false;
  636.  
  637. func set_ability_power_levelup(ExistingAblPwr):
  638. """
  639. Increases the ability power using the formulae outlined in the
  640. Design Bible. Requires that the Existing Ability Power be passed
  641. to it as a non-zero integer, or it will return false.
  642.  
  643. Keyword arguments:
  644. ExistingAblPwr -- Integer representing the Ability Power (Required)
  645. """
  646. if typeof(ExistingAblPwr) == TYPE_INT:
  647. if ExistingAblPwr > 0:
  648. var DiceRollObj = DiceObj.new()
  649. AblPwrDelta = DiceRollObj.roll_the_dice(D20_MIN, D20_MAX)
  650. DSAbilityPower = ExistingAblPwr + floor(.5 * AblPwrDelta)
  651. return DSAbilityPower
  652. else:
  653. return false
  654. else:
  655. return false
  656.  
  657. func get_ability_power():
  658. """
  659. Returns the ability power for the Character.
  660. """
  661. return DSAbilityPower
  662.  
  663. # Effect Resistance
  664. func set_effect_resistance(Const, Str):
  665. """
  666. Sets the initial Effect Resistance for a character on Creation.
  667.  
  668. Keyword arguments:
  669. Const -- Integer representing Consitution. (Required)
  670. Str -- Integer representing Strength. (Required)
  671. """
  672. if typeof(Const) != TYPE_INT:
  673. return false
  674.  
  675. if typeof(Str) != TYPE_INT:
  676. return false
  677.  
  678. if Const < 0:
  679. return false
  680.  
  681. if Str < 0:
  682. return false
  683.  
  684. DSEffectRes = Const * floor(((1/3) * Str))
  685. return DSEffectRes
  686.  
  687. func set_effect_resistance_levelup(Strength):
  688. """
  689. Increments the Effect Resistance when the player levels up.
  690.  
  691. Keyword arguments:
  692. Strength -- Integer representing the character\'s strength. (Required)
  693. """
  694. if typeof(Strength) != TYPE_INT:
  695. return false
  696.  
  697. if Strength < 0:
  698. return false
  699.  
  700. var MaxStrength = Strength^2
  701. var DiceRollObj = DiceObj.new()
  702. MaxStrVal = DiceRollObj.roll_the_dice(1, MaxStrength)
  703.  
  704. DSEffectRes = DSEffectRes + floor(MaxStrVal)
  705. return DSEffectRes
  706.  
  707. func get_effect_resistance():
  708. """
  709. Returns the numeric value for the Effect Resistance.
  710. """
  711. return DSEffectRes
  712.  
  713. # Inventory Capactiy
  714. func set_inventory_capacity(Str):
  715. """
  716. Sets the Inventory Capacity for the Character. Requires the Strength
  717. as a non-zero, non-negative Integer, or else it returns false.
  718.  
  719. Keyword arguments:
  720. Str -- Measure of the Character's strength. (Required)
  721. """
  722. if typeof(Str) == TYPE_INT:
  723. if Str > 0:
  724. DSInventoryCapacity = Str * INVENTORY_MULTI
  725. DSCurrentInventoryUsage = 0
  726. return DSInventoryCapacity
  727. else:
  728. return false
  729. else:
  730. return false
  731.  
  732. func change_inventory_capacity(inc, dec, delta, CurrentInvCap):
  733. """
  734. Based on whatever is passed, either increases or decrease the
  735. current measure of inventory capacity based on the passed Delta,
  736. which must be a non-negative, non-zero Integer.
  737.  
  738. Increment or Decrement, both which default to false, cannot be left as
  739. false or else the method will return false. One must be set to true to
  740. indicate expected behavior. Similarly, if both are true, the method will
  741. return false.
  742.  
  743. The Current Inventory Capacity must be passed as well, as a
  744. non-negative, non-zero Integer. Or else, it will return false.
  745.  
  746. If the new change to inventory goes below or equals zero, the method
  747. will return a string 'NegativeCapacityError' and if it goes above the
  748. max inventory it will return 'ExceedsCapacityError'. Otherwise, it
  749. will return the new Inventory Capacity.
  750.  
  751. Keyword arguments:
  752. inc -- Boolean argument to process change as an increment. (Required)
  753. dec -- Boolean argument to process change as a decrement. (Required)
  754. delta -- Integer representing value to add or remove from
  755. Inventory Size. (Required)
  756. CurrentInvCap -- Integer represeting value of the inventory before
  757. altering. (Required)
  758. """
  759. if (typeof(inc) == TYPE_BOOL) and (typeof(dec) == TYPE_BOOL):
  760. if ((inc == true) and (dec == true)) or ((inc == false) and (dec == false)):
  761. return false
  762.  
  763. if typeof(delta) != TYPE_INT and delta <= 0:
  764. return false
  765.  
  766. if typeof(CurrentInvCap) != TYPE_INT and CurrentInvCap <= 0:
  767. return false
  768.  
  769. if (inc == true):
  770. NewInvUsage = CurrentInvCap + delta
  771.  
  772. if(NewInvUsage > DSInventoryCapacity):
  773. return "ExceedsCapacityError"
  774. elif(NewInvUsage <= 0):
  775. return "NegativeCapacityError"
  776. else:
  777. DSCurrentInventoryUsage = NewInvUsage
  778. return DSCurrentInventoryUsage
  779. elif (dec == true):
  780. NewInvUsage = CurrentInvCap - delta
  781.  
  782. if(NewInvUsage > DSInventoryCapacity):
  783. return "ExceedsCapacityError"
  784. elif(NewInvUsage <= 0):
  785. return "NegativeCapacityError"
  786. else:
  787. DSCurrentInventoryUsage = NewInvUsage
  788. return DSCurrentInventoryUsage
  789.  
  790. func get_max_inventory_capacity():
  791. """
  792. Gets the maximum inventory capacity.
  793. """
  794. return DSInventoryCapacity
  795.  
  796. func get_current_inventory_capacity():
  797. """
  798. Gets the current inventory capacity.
  799. """
  800. return DSCurrentInventoryUsage
  801.  
  802. # Agility
  803. func set_agility_creation(Srn, Con):
  804. """
  805. Set the starting agility value. Requires the Strength and
  806. Constitution to be set in place, or else it will return false
  807.  
  808. Keyword arguments:
  809. Srn -- Character's Strength. (Required)
  810. Con -- Character's Constitution (Required)
  811. """
  812. if (typeof(Srn) == TYPE_INT) and (typeOf(Con) == TYPE_INT):
  813. if (Srn > 0) and (Con > 0):
  814. DSAgility = floor((1/2) * Srn) + floor((1/3) * Con)
  815. return DSAgility
  816. else:
  817. return false
  818. else:
  819. return false
  820.  
  821. func set_agility_levelup(DSAgility):
  822. """
  823. Increases the Agility attribute at Level up.
  824. """
  825. DSAgility = DSAgility + (floor(randf()*.5+1) * DSAgility)
  826. return DSAgility
  827.  
  828. func get_agility():
  829. """
  830. Returns the Agility Attribute for the Character.
  831. """
  832. return DSAgility
  833.  
  834. # Critical Thinking
  835. func set_critical_thinking(Int, Pro):
  836. """
  837. Set the starting Critical Thinking value. Requires the Intelligence
  838. and Providence to be set, or else it will return false
  839.  
  840. Keyword arguments:
  841. Int -- Character's Intelligence. (Required)
  842. Pro -- Character's Providence (Required)
  843. """
  844.  
  845. # TODO Sanity Check
  846. if (typeof(Int) == TYPE_INT) and (typeof(Pro) == TYPE_INT):
  847. if (Int > 0) && (Pro > 0):
  848. # Calculate the Providence Caveat
  849. randomize();
  850. var caveatSeed = randi()%4097+1
  851. var ProvidenceMulti = 0;
  852.  
  853. if (caveatSeed >= 1) and (caveatSeed <= Pro):
  854. ProvidenceMulti = floor(Int / 2);
  855. else:
  856. ProvidenceMulti = 0
  857.  
  858. DSCriticalThinking = (Int * 2) + ProvidenceMulti
  859. return DSCriticalThinking
  860. else:
  861. return false
  862. else:
  863. return false
  864.  
  865. func get_critical_thinking():
  866. """
  867. Returns the Character's Critical Thinking.
  868. """
  869. return DSCriticalThinking
  870.  
  871. # Economics
  872. func set_economics(nti):
  873. """
  874. Assigns Economic Points on Character Creation. Requires the
  875. Intelligence Attribute to be set. If not set or is zero,
  876. the function returns false.
  877.  
  878. Keyword arguments:
  879. nti -- Character's Intelligence. (Required)
  880. """
  881.  
  882. if typeof(nti) == TYPE_INT:
  883. if nti > 0:
  884. var coin = CoinFlipObj.new()
  885. var modulo_operator
  886.  
  887. if(coin.flip_coin() == "H"):
  888. modulo_operator = 1/2;
  889. else:
  890. modulo_operator = 1/3;
  891.  
  892. DSEconomics = modulo_operator * (nti * 4)
  893. return DSEconomics
  894. else:
  895. return false
  896. else:
  897. return false
  898.  
  899. func get_economics():
  900. """
  901. Returns the Character's understanding of Economics.
  902. """
  903. return DSEconomics
  904.  
  905. # Communication
  906. func set_communication_creation(Int, Per, Pro):
  907. """
  908. Assigns Communication points on Character Creation. Requires the
  909. Intelligence, Perception, and Providence attributes to be set. If
  910. not set or is zero, the function returns false.
  911.  
  912. Keyword arguments:
  913. Int -- Character's Intelligence (Required)
  914. Per -- Character's Perception (Required)
  915. Pro -- Character's Providence (Required)
  916. """
  917. if (typeof(Int) == TYPE_INT) and (typeof(Per) == TYPE_INT) and (typeof(Pro) == TYPE_INT):
  918. if (Int > 0) and (Per > 0) and (Pro > 0):
  919. var ProvMultiplier = randi()%11+1
  920. DSCommunication = Int * floor((1/3) * (Per * (Pro * ProvMultiplier)))
  921. return DSCommunication
  922. else:
  923. return false
  924. else:
  925. return false
  926.  
  927. func set_communication_levelup():
  928. """
  929. Increase the Character's understanding of Communication. This assumes
  930. that the the Intelligence and Perception are set in the Object
  931. instance.
  932.  
  933. TODO: Maybe move to arguments.
  934. """
  935. DSCommunication = floor((1/3) * (PAIntelligence + PAPerception))
  936. return DSCommunication;
  937.  
  938. func get_communication():
  939. """
  940. Returns the value of the Communication attribute.
  941. """
  942. return DSCommunication
  943.  
  944. # Crafting
  945. func set_crafting_creation(Int, Pro):
  946. """
  947. Sets the crafting value for the Character on creation. This value remains
  948. unchanged throughout the game. All values must be non-zero, non-negative
  949. integers or else the method returns false.
  950.  
  951. Keyword arguments:
  952. Int -- The Character's Intelligence. (Required)
  953. Pro -- The Character's Providence. (Required)
  954. """
  955. if (typeof(Int) == TYPE_INT) and (typeof(Pro) == TYPE_INT):
  956. if (Int > 0) and (Pro > 0):
  957. var DiceRollObj = DiceObj.new()
  958. CraftingRandomAdd = DiceRollObj.roll_the_dice(D20_MIN, Pro)
  959. DSFabrication = (Int * 3) + floor(CraftingRandomAdd)
  960. return DSFabrication
  961. else:
  962. return false
  963. else:
  964. return false
  965.  
  966. func get_crafting():
  967. """
  968. Returns Crafting Score for the Character.
  969. """
  970. return DSFabrication
  971.  
  972. # ----
  973. # Skills Modifying Methods
  974. # ----
  975. # TODO deferreds to update other attributes
Advertisement
RAW Paste Data Copied
Advertisement