forked from XelaPy/PyTFall
/
classes - characters.rpy
4876 lines (4080 loc) · 224 KB
/
classes - characters.rpy
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Characters classes and methods:
init -9 python:
###### Character Helpers ######
class SmartTracker(collections.MutableSequence):
def __init__(self, instance, be_skill=True):
self.instance = instance # Owner of this object, this is being instanciated as character.magic_skills = SmartTracker(character)
self.normal = set() # Normal we concider anything that's been applied by normal game operations like events, loading routines and etc.
self.items = dict() # Stuff that's been applied through items, it's a counter as multiple items can apply the same thing (like a trait).
self.be_skill = be_skill # If we expect a be skill or similar mode.
self.list = _list()
def __len__(self): return len(self.list)
def __getitem__(self, i): return self.list[i]
def __delitem__(self, i): del self.list[i]
def __setitem__(self, i, v):
self.list[i] = v
def insert(self, i, v):
self.list.insert(i, v)
def __str__(self):
return str(self.list)
def append(self, item, normal=True):
# Overwriting default list method, always assumed normal game operations and never adding through items.
# ==> For battle & magic skills:
if self.be_skill:
if isinstance(item, basestring):
if item in store.battle_skills:
item = store.battle_skills[item]
else:
devlog.warning("Tried to apply unknown skill %s to %s!" % (item, self.instance.__class__))
return
if normal: # Item applied by anything other than that
self.normal.add(item)
else:
self.items[item] = self.items.get(item, 0) + 1
# The above is enough for magic/battle skills, but for traits... we need to know if the effects should be applied.
if item in self.normal or self.items.get(item, 0) > 0:
if not item in self.list:
self.list.append(item)
return True
def remove(self, item, normal=True):
# Overwriting default list method.
# ==> For battle & magic skills:
if self.be_skill:
if isinstance(item, basestring):
if item in store.battle_skills:
item = store.battle_skills[item]
else:
devlog.warning("Tried to remove unknown skill %s from %s!" % (item, self.instance.__class__))
return
if normal:
if item in self.normal:
self.normal.remove(item)
else:
self.items[item] = self.items.get(item, 0) - 1
# The above is enough for magic/battle skills, but for traits... we need to know if the effects should be applied.
if not item in self.normal and self.items.get(item, 0) <= 0:
if item in self.list:
self.list.remove(item)
return True
class SmartTrackerOld(_list):
"""
Basically a smart list that tracks anything that can be added by items and events/game.
Prevents removal when unequipping items and/or other types of ralated errors/bugs.
"""
def __init__(self, instance, be_skill=True):
_list.__init__(self)
self.instance = instance # Owner of this object, this is being instanciated as character.magic_skills = SmartTracker(character)
self.normal = set() # Normal we concider anything that's been applied by normal game operations like events, loading routines and etc.
self.items = dict() # Stuff that's been applied through items, it's a counter as multiple items can apply the same thing (like a trait).
self.be_skill = be_skill # If we expect a be skill or similar mode.
# raise Exception("zzzz", self.instance)
def __getattr__(self, item):
raise AttributeError("%s object has no attribute named %r, __dict__: %s" %
(self.__class__.__name__, item, self.__dict__))
def set_instance(self, instance):
self.instance = instance
def append(self, item, normal=True):
# Overwriting default list method, always assumed normal game operations and never adding through items.
# ==> For battle & magic skills:
if self.be_skill:
if isinstance(item, basestring):
if item in store.battle_skills:
item = store.battle_skills[item]
else:
devlog.warning("Tried to apply unknown skill %s to %s!" % (item, self.instance.__class__))
return
if normal: # Item applied by anything other than that
self.normal.add(item)
else:
self.items[item] = self.items.get(item, 0) + 1
# The above is enough for magic/battle skills, but for traits... we need to know if the effects should be applied.
if item in self.normal or self.items.get(item, 0) > 0:
if not item in self:
super(SmartTracker, self).append(item)
return True
def remove(self, item, normal=True):
# Overwriting default list method.
# ==> For battle & magic skills:
if self.be_skill:
if isinstance(item, basestring):
if item in store.battle_skills:
item = store.battle_skills[item]
else:
devlog.warning("Tried to remove unknown skill %s from %s!" % (item, self.instance.__class__))
return
if normal:
if item in self.normal:
self.normal.remove(item)
else:
self.items[item] = self.items.get(item, 0) - 1
# The above is enough for magic/battle skills, but for traits... we need to know if the effects should be applied.
if not item in self.normal and self.items.get(item, 0) <= 0:
if item in self:
super(SmartTracker, self).remove(item)
return True
class Traits(SmartTracker):
def __init__(self, *args, **kwargs):
"""
Trait effects are being applied per level on activation of a trait and on level-ups.
"""
# raise Exception(args[0])
# SmartTracker.__init__(self, args[0])
super(Traits, self).__init__(args[0])
# self.instance = args[0]
self.ab_traits = set() # Permenatly blocked traits (Absolute Block Traits)
self.blocked_traits = set() # Blocked traits
self.basetraits = set() # A set with basetraits (2 maximum)
# if not hasattr(self, "be_skills"):
# raise Exception("Meow~")
def __getattr__(self, item):
raise AttributeError("%s object has no attribute named %r" %
(self.__class__.__name__, item))
def __contains__(self, item):
if isinstance(item, basestring):
if item in store.traits: item = store.traits[item]
else: return False
return super(Traits, self).__contains__(item)
@property
def base_to_string(self):
return ", ".join(sorted(list(str(t) for t in self.basetraits)))
def apply(self, trait, truetrait=True):
"""
Activates trait and applies it's effects all the way up to a current level of the characters.
Truetraits basially means that the trait is not applied throught items (Jobs, GameStart, Events and etc.)
"""
# If we got a string with a traits name. Let the game throw an error otherwise.
if not isinstance(trait, Trait):
trait = store.traits[trait]
char = self.instance
# All the checks required to make sure we can even apply this fucking trait: ======================>>
if trait.sex not in ["unisex", char.gender]:
return
# We cannot allow "Neutral" element to be applied if there is at least one element present already:
if trait.elemental and trait.id == "Neutral":
if self.instance.elements:
return
# Blocked traits:
if trait in self.ab_traits | self.blocked_traits:
return
# Unique Traits:
if trait.personality and list(t for t in self if t.personality):
return
if trait.race and list(t for t in self if t.race):
return
if trait.breasts and list(t for t in self if t.breasts):
return
if trait.body and list(t for t in self if t.body):
return
if trait.personality:
char.personality = trait
if trait.race:
char.race = trait
if trait.breasts:
char.breasts = trait
if trait.body:
char.body = trait
# We need to make sure that no more than x + len(basetraits) of basetraits can be applied, atm x is 4:
if trait.basetrait:
if trait not in self.basetraits:
if trait.higher_tiers and list(traits[t] for t in trait.higher_tiers if t in self.basetraits):
allowed = 4 + len(self.basetraits)
bt = len(list(t for t in self if t.basetrait))
if bt == allowed:
return
elif bt > allowed:
devlog.warning("BASE TRAITS OVER THE ALLOWED MAX! CHECK Traits.apply method!")
return
if not super(Traits, self).append(trait, truetrait):
return
# If we got here... we can apply the effect? Maybe? Please? Just maybe? I am seriouslly pissed at this system right now... ===========>>>
stats = self.instance.stats
# If the trait is a basetrait:
if trait in self.basetraits:
multiplier = 2 if len(self.basetraits) == 1 else 1
for stat in trait.init_lvlmax: # Mod value setting
if stat in stats:
stats.lvl_max[stat] += trait.init_lvlmax[stat] * multiplier
else:
msg = "'%s' trait tried to apply unknown init lvl max stat: %s!"
devlog.warning(str(msg % (trait.id, stat)))
for stat in trait.init_max: # Mod value setting
if stat in stats:
stats.max[stat] += trait.init_max[stat] * multiplier
else:
msg = "'%s' trait tried to apply unknown init max stat: %s!"
devlog.warning(str(msg % (trait.id, stat)))
for stat in trait.init_mod: # Mod value setting
if stat in stats:
stats.stats[stat] += trait.init_mod[stat] * multiplier
else:
msg = "'%s' trait tried to apply unknown init max stat: %s!"
devlog.warning(str(msg % (trait.id, stat)))
for skill in trait.init_skills: # Mod value setting
if skill in stats.skills:
stats.skills[skill][0] += trait.init_skills[skill][0] * multiplier
stats.skills[skill][1] += trait.init_skills[skill][1] * multiplier
else:
msg = "'%s' trait tried to apply unknown init skillt: %s!"
devlog.warning(str(msg % (trait.id, skill)))
# Only for body traits:
if trait.body:
if trait.mod_ap:
self.instance.baseAP += trait.mod_ap
for key in trait.max:
if key in stats.max:
stats.max[key] += trait.max[key]
else:
msg = "'%s' trait tried to apply unknown max stat: %s!"
devlog.warning(str(msg % (trait.id, key)))
for key in trait.min:
# Preventing traits from messing up minimums of stats by pushing them into negative territory. @Review: No longer required as per new stats code.
if key in stats.min:
stats.min[key] += trait.min[key]
else:
msg = "'%s' trait tried to apply unknown min stat: %s!"
devlog.warning(str(msg % (trait.id, key)))
for entry in trait.blocks:
if entry in traits:
self.blocked_traits.add(traits[entry])
else:
devlog.warning(str("Tried to block unknown trait: %s, id: %s, class: %s" % (entry, char.id, char.__class__)))
# For now just the girls get effects...
if hasattr(char, "effects"):
for entry in trait.effects:
char.enable_effect(entry)
if trait.mod_stats:
if hasattr(char, "upkeep"):
char.upkeep += trait.mod_stats.get("upkeep", [0, 0])[0]
if hasattr(char, "disposition"):
char.disposition += trait.mod_stats.get("disposition", [0, 0])[0]
for level in xrange(char.level+1):
char.stats.apply_trait_statsmod(trait)
if hasattr(trait, "mod_skills"):
for key in trait.mod_skills:
if key in char.SKILLS:
sm = stats.skills_multipliers[key] # skillz muplties
m = trait.mod_skills[key] # mod
sm[0] += m[0]
sm[1] += m[1]
sm[2] += m[2]
else:
msg = "'%s' trait tried to apply unknown skill: %s!"
devlog.warning(str(msg % (trait.id, key)))
# Adding resisting elements and attacks:
for i in trait.resist:
self.instance.resist.append(i)
# NEVER ALLOW NEUTRAL ELEMENT WITH ANOTHER ELEMENT!
if trait.elemental:
if trait.id != "Neutral" and traits["Neutral"] in self:
self.remove(traits["Neutral"])
# Finally, make sure stats are working:
char.stats.normalize_stats()
def remove(self, trait, truetrait=True):
"""
Removes trait and removes it's effects gained up to a current level of the characters.
Truetraits basially means that the trait is not applied throught items (Jobs, GameStart, Events and etc.)
"""
# If we got a string with a traits name. Let the game throw an error otherwise.
if not isinstance(trait, Trait):
trait = store.traits[trait]
char = self.instance
if trait.sex not in ["unisex", char.gender]:
return
# We Never want to remove a base trait:
if trait in self.basetraits:
return
# WE NEVER REMOVE PERMANENT TRAITS FAMILY:
if any([trait.personality, trait.race, trait.breasts, trait.body]):
return
if not super(Traits, self).remove(trait, truetrait):
return
stats = char.stats
for key in trait.max:
if key in stats.max:
stats.max[key] -= trait.max[key]
else:
devlog.warning(str('Maximum Value: %s for Trait: %s does not exist' % (key, trait.id)))
for key in trait.min:
if key in stats.min:
# Preventing traits from messing up minimums of stats by pushing them into negative territory. @Review: No longer required as per new stats code.
# if(self.stats.min[key] - trait.min[key]) >= 0:
stats.min[key] -= trait.min[key]
else:
msg = "'%s' trait tried to apply unknown min stat: %s!"
devlog.warning(str(msg % (trait.id, key)))
if trait.blocks:
_traits = set()
for entry in trait.blocks:
if entry in traits:
_traits.add(traits[entry])
else:
devlog.warning(str("Tried to block unknown trait: %s, id: %s, class: %s" % (entry, char.id, char.__class__)))
self.blocked_traits -= _traits
# Ensure that blocks forced by other traits were not removed:
for entry in self:
self.blocked_traits = self.blocked_traits.union(entry.blocks)
# For now just the girls get effects...
if isinstance(char, Char):
for entry in trait.effects:
self.instance.disable_effect(entry)
if trait.mod_stats:
if hasattr(char, "upkeep"):
char.upkeep -= trait.mod_stats.get("upkeep", [0, 0])[0]
if hasattr(char, "disposition"):
char.disposition -= trait.mod_stats.get("disposition", [0, 0])[0]
for level in xrange(char.level+1):
char.stats.apply_trait_statsmod(trait, reverse=True)
if hasattr(trait, "mod_skills"):
for key in trait.mod_skills:
if key in char.SKILLS:
sm = stats.skills_multipliers[key] # skillz muplties
m = trait.mod_skills[key] # mod
sm[0] -= m[0]
sm[1] -= m[1]
sm[2] -= m[2]
else:
msg = "'%s' trait tried to apply unknown skill: %s!"
devlog.warning(str(msg % (trait.id, key)))
# Remove resisting elements and attacks:
for i in trait.resist:
self.instance.resist.remove(i)
# We need to check if one of the traits still may apply resistance:
# for t in self:
# if i in t.resist:
# self.instance.resist.append(i)
# break
# We add the Neutral element if there are no elements left at all...
if not self.instance.elements:
self.apply("Neutral")
# Finally, make sure stats are working:
char.stats.normalize_stats()
class Rank(_object): # Will not be used for the next release...
"""
Ranks, currently not in use in the game.
"""
WhRANKS = OrderedDict()
WhRANKS["0"]=dict(name=('No Rank: Kirimise', '(Almost beggar)'), price=0)
WhRANKS["1"]=dict(name=("Rank 1: Heya-Mochi", "(Low-class prostitute)"), skills={"oral": 10, "vaginal": 10, "anal": 5}, total_skill=100, price=1000, exp=10000) # note: refinement is not a stat anymore!
WhRANKS["2"]=dict(name=("Rank 2: Zashiki-Mochi", "(Middle-class Prostitute"), skills={"oral": 25, "vaginal": 15, "anal": 15}, total_skill=300, price=3000, exp=25000)
WhRANKS["3"]=dict(name=("Rank 3: Tsuke-Mawashi", "(Courtesan)"), skills={"oral": 55, "vaginal": 40, "anal": 25}, total_skill=600, price=5000, exp=50000)
WhRANKS["4"]=dict(name=("Rank 4: Chûsan", "(Famous)"), skills={"oral": 100, "vaginal": 80, "anal": 50}, total_skill=1000, stats={"refinement": 100}, price=7500, exp=100000)
WhRANKS["5"]=dict(name=("Rank 5: Yobidashi", "(High-Class Courtesan)"), skills={"oral": 250, "vaginal": 150, "anal": 130}, total_skill=1250, stats={"refinement": 150}, price=10000, exp=250000)
WhRANKS["6"]=dict(name=("Rank 6: Koshi", "(Nation famous)"), skills={"oral": 500, "vaginal": 500, "anal": 500}, total_skill=2500, stats={"refinement": 500}, price=25000, exp=400000)
WhRANKS["7"]=dict(name=("Rank 7: Tayu", "(Legendary)"), skills={"oral": 1500, "vaginal": 1500, "anal": 1500}, total_skill=5000, stats={"refinement": 800}, price=50000, exp=800000)
WaRANKS = OrderedDict()
WaRANKS["0"]=dict(name=('No Rank', 'Nub with a stick...'), price=0)
WaRANKS["1"]=dict(name=("Rank 1", "Thug"), skills={}, total_skill=100, stats={}, price=1000, exp=10000)
WaRANKS["2"]=dict(name=("Rank 2", "Sword Sister"), skills={}, total_skill=300, stats={}, price=3000, exp=25000)
WaRANKS["3"]=dict(name=("Rank 3", "War Maiden"), skills={}, total_skill=600, stats={}, price=5000, exp=50000)
WaRANKS["4"]=dict(name=("Rank 4", "Famous"), skills={}, total_skill=1000, stats={}, price=7500, exp=100000)
WaRANKS["5"]=dict(name=("Rank 5", "War Maiden"), skills={}, total_skill=1250, stats={}, price=10000, exp=250000)
WaRANKS["6"]=dict(name=("Rank 6", "Valkyrie"), skills={}, total_skill=2500, stats={}, price=25000, exp=400000)
WaRANKS["7"]=dict(name=("Rank 7", "Legendary"), skills={}, total_skill=5000, stats={}, price=50000, exp=800000)
StRANKS = OrderedDict()
StRANKS["0"]=dict(name=('No Rank', 'Nub wiggling her ass...'), price=0)
StRANKS["1"]=dict(name=("Rank 1", "Stripper"), skills={"strip": 50}, total_skill=100, price=1000, exp=10000)
StRANKS["2"]=dict(name=("Rank 2", "Lap Dancer"), skills={"strip": 100}, total_skill=300, price=3000, exp=25000)
StRANKS["3"]=dict(name=("Rank 3", "Seductress"), skills={"strip": 250}, total_skill=600, price=5000, exp=50000)
StRANKS["4"]=dict(name=("Rank 4", "Famous"), skills={"strip": 500}, total_skill=1000, stats={}, price=7500, exp=100000)
StRANKS["5"]=dict(name=("Rank 5", "Ecdysiastn"), skills={"strip": 1000}, total_skill=1250, stats={}, price=10000, exp=250000)
StRANKS["6"]=dict(name=("Rank 6", "Temptress"), skills={"strip": 2500}, total_skill=2500, stats={}, price=25000, exp=400000)
StRANKS["7"]=dict(name=("Rank 7", "Legendary"), skills={"strip": 5000}, total_skill=5000, stats={}, price=50000, exp=800000)
SgRANKS = OrderedDict()
SgRANKS["0"]=dict(name=('No Rank', 'Nub breaking the china...'), price=0)
SgRANKS["1"]=dict(name=("Rank 1", "Wench"), skills={"service": 50}, total_skill=100, price=1000, exp=10000)
SgRANKS["2"]=dict(name=("Rank 2", "Servant"), skills={"service": 100}, total_skill=300, price=3000, exp=25000)
SgRANKS["3"]=dict(name=("Rank 3", "Maid"), skills={"service": 250}, total_skill=600, price=5000, exp=50000)
SgRANKS["4"]=dict(name=("Rank 4", "Chambermaid"), skills={"service": 500}, total_skill=1000, stats={}, price=7500, exp=100000)
SgRANKS["5"]=dict(name=("Rank 5", "Housekeeper"), skills={"service": 1000}, total_skill=1250, stats={}, price=10000, exp=250000)
SgRANKS["6"]=dict(name=("Rank 6", "Famous"), skills={"service": 2500}, total_skill=2500, stats={}, price=25000, exp=400000)
SgRANKS["7"]=dict(name=("Rank 7", "Legendary"), skills={"service": 5000}, total_skill=5000, stats={}, price=50000, exp=800000)
"""
Handles ranks for characters. Stores all related data and returns the correct rank/requirement/updates.
"""
def __init__(self):
self.current_rank = None
self.n = None
class Finances(_object):
"""Helper class that handles finance related matters in order to reduce the size of Characters/Buildings classes.
TODO: This is fairly old, I should be able to do better now.
TODO: Naming of methods could be better.
"""
def __init__(self, *args, **kwargs):
"""
instance = reference to Character object
"""
self.instance = args[0]
"""
Income/expense log consists of personal, wages and tips dicts.
Private = Private (logs with acutal gold increases/decreases).
Work(Wages) = Earned but not settled (just a log to be settled later in next day methods).
Tips = Same as wages, only for tips.
Cost = What did this girl cost to the player over the day.
"""
self.game_fin_log = dict()
self.daily_income_log = dict(work=dict(), tips=dict(), private=dict())
self.daily_expense_log = dict(work=dict(), private=dict(), cost=dict())
self.income_tax_debt = 0
self.property_tax_debt = 0
# Logging data:
def log_work_income(self, value, kind):
"""This is for Buildings.
"""
self.daily_income_log["work"][kind] = self.daily_income_log["work"].get(kind, 0) + int(round(value))
def log_work_expense(self, value, kind):
"""This is for Buildings.
"""
self.daily_expense_log["work"][kind] = self.daily_expense_log["work"].get(kind, 0) + int(round(value))
def log_wage(self, value, kind):
self.daily_income_log["work"][kind] = self.daily_income_log["work"].get(kind, 0) + int(round(value))
def log_tips(self, value, kind):
if not "tips" in self.daily_income_log:
self.daily_income_log["tips"] = dict()
self.daily_income_log["tips"][kind] = self.daily_income_log["tips"].get(kind, 0) + int(round(value))
def log_income(self, value, kind):
"""Logs private Income.
"""
self.daily_income_log["private"][kind] = self.daily_income_log["private"].get(kind, 0) + int(round(value))
def log_expense(self, value, kind):
"""Logs private expence.
"""
self.daily_expense_log["private"][kind] = self.daily_expense_log["private"].get(kind, 0) + int(round(value))
def log_cost(self, value, kind):
"""
This logs how much an object (usually a character) has cost the player over the day.
This is a part of that objects class and is being recorded to players class as a sum of all characters.
While not technically an expence to a character, it is being recorded to that dict.
"""
self.daily_expense_log["cost"][kind] = self.daily_expense_log["cost"].get(kind, 0) + int(round(value))
def take_money(self, value, reason="Other"):
value = int(round(value))
if value <= self.instance.gold:
self.log_expense(value, reason)
self.instance.gold -= value
return True
else:
return False
def add_money(self, value, reason="Other"):
value = int(round(value))
self.log_income(value, reason)
self.instance.gold += value
# Retrieving data:
def get_work_income(self, kind="all", day=None):
"""Retrieve work income (for buildings/chars?)
kind = "all" means any income earned on the day.
"""
if day and day >= store.day:
raise Exception("Day on income retrieval must be lower than the current day!")
if not day:
d = self.daily_income_log["work"]
else:
d = self.game_fin_log[str(day)][0]["work"]
if kind == "all":
return sum(val for val in d.values())
elif kind in d:
return d[kind]
else:
raise Exception("Income kind: {} is not valid!".format(kind))
def get_total_taxes(self, days):
char = self.instance
income = dict()
businesses = [b for b in char.buildings if hasattr(b, "fin")]
for b in businesses:
for _day in b.fin.game_fin_log:
if int(_day) > day - days:
for key in b.fin.game_fin_log[_day][0]["private"]:
income[key] = income.get(key, 0) + b.fin.game_fin_log[_day][0]["private"][key]
for key in b.fin.game_fin_log[_day][0]["work"]:
income[key] = income.get(key, 0) + b.fin.game_fin_log[_day][0]["work"][key]
income = sum(income.values())
if income <= 5000:
tax = 0
elif income <= 25000:
tax = int(round(income*0.1))
elif income <= 50000:
tax = int(round(income*0.2))
elif income <= 100000:
tax = int(round(income*0.3))
elif income <= 200000:
tax = int(round(income*0.4))
else:
tax = int(round(income*0.45))
for b in businesses:
tax += int(b.price*0.04)
for ch in char.chars:
if ch.status == "slave":
tax += int(ch.fin.get_price()*0.05)
return tax
# ================================>
# Rest
def expects_wage(self):
"""
Amount of money each character expects to get paid for her skillset.
"""
# TODO: To be revised after SKILLS!
char = self.instance
wage = 100
if "Dedicated" in char.traits: # the trait decreases wage, this check should remain after revising! - DarkTl
wage = int(wage*0.65)
# if traits['Prostitute'] in char.occupations:
# bw = 5 # Base wage
# sm = bw*((1+char.charisma/5 + char.refinement/5 + char.reputation/4 + char.fame/4)/100) # Stats Mod
# osm = (char.anal + char.normalsex + char.blowjob + char.lesbian) / 4 * (char.rank / 10 + 1) # Occupational Stats M
# wage = (sm*osm)/5 + bw
# elif traits['Stripper'] in char.occupations:
# bw = 2
# sm = bw*(char.charisma/4 + char.refinement/5 + char.reputation/4 + char.fame/4)
# osm = char.strip*char.agility/100
# wage = (sm+osm)/5 + bw
# elif 'Server' in char.occupations:
# bw = 10
# sm = char.charisma/5 + char.agility/2 + char.refinement/4
# osm = char.service*bw
# wage = sm/2+osm/100
# elif 'Warrior' in char.occupations or isinstance(self.instance, Player):
# # Here we include MC for the attack event as well.
# bw = 15
# sm = char.agility/100+char.fame/4 + char.reputation/3
# osm = (char.attack + char.defence + char.magic/2)/100 + bw
# wage = bw+sm*osm
# else:
# for stat in char.stats:
# if stat not in ["disposition", "joy", "health", "vitality"]: #, "mood"
# wage += getattr(char, stat)
# wage = wage/2
# # Normalize:
# wage = int(wage)
# if wage < 20:
# wage = 20
return wage
def settle_wage(self):
"""
Settle wages between girls and player.
Called during next day method per each individual girl.
Right now being used for Businesses only, all FG profit goes directly into MC's pockets.
"""
char = self.instance
if self.wage_conditions():
total_wage = sum(self.daily_income_log["work"].values())
hero.add_money(total_wage, reason="Businesses")
if char.status != "slave":
if char.wagemod >= 100:
amount = int(self.expects_wage() + int(round(self.expects_wage()*0.01*(char.wagemod-100))))
if hero.take_money(amount, reason="Wages"):
self.add_money(amount, reason="Wages")
self.log_cost(amount, "Wages")
if isinstance(char.location, Building):
char.location.fin.log_work_expense(amount, "Wages")
if char.disposition < 700:
char.disposition += int(round((char.wagemod-100)*0.1))
char.joy += int(round((char.wagemod-100)*0.1))
elif char.wagemod< 100:
amount = int(self.expects_wage() - int(round(self.expects_wage()*0.01*(100-char.wagemod))))
if hero.take_money(amount, reason="Wages"):
self.log_cost(amount, "Wages")
self.add_money(amount, reason="Wages")
if isinstance(char.location, Building):
char.location.fin.log_work_expense(amount, "Wages")
else:
amount = int(self.expects_wage()*0.01*(char.wagemod))
if hero.take_money(amount, reason="Wages"):
self.add_money(amount, reason="Wages")
self.log_cost(amount, "Wages")
if isinstance(char.location, Building):
char.location.fin.log_work_expense(amount, "Wages")
if char.disposition < 700:
char.disposition += int(round((char.wagemod)*0.2))
char.joy += int(round((char.wagemod)*0.2))
def wage_conditions(self):
char = self.instance
return char.action not in ["Rest", "AutoRest"] or (char.location != "Streets" and not in_training_location(char))
def get_price(self):
# TODO: To be revised after skills are added!
char = self.instance
# if char.status == 'slave':
# if 'Prostitute' in char.basetraits:
# bp = 3000 # Base Price
# sp = 2 * (char.charisma + char.reputation + char.fame + char.constitution + char.character) + 3 * char.refinement
# ssp = 2 * (char.anal + char.normalsex + char.blowjob + char.lesbian) # Sex Price
# if sp > 1200:
# sp = sp * 1.2
# if ssp > 850:
# ssp = ssp * 1.4
# price = bp + sp + ssp
# return int(price)
# elif 'Stripper' in char.basetraits:
# bp = 3900 # Base Price
# sp = 2 * (char.charisma + char.reputation + char.fame + char.constitution + char.character) + 3 * char.refinement
# ssp = 2 * 4 * (char.strip) # Sex Price
# if sp > 1200:
# sp = sp * 1.2
# if ssp > 850:
# ssp = ssp * 1.4
# price = bp + sp + ssp
# return int(price)
# elif 'Server' in char.occupations:
# bp = 3500 # Base Price
# sp = 2 * (char.charisma + char.reputation + char.fame + char.constitution + char.character) + 3 * char.refinement
# ssp = 2 * 4 * (char.service) # Sex Price
# if sp > 1200:
# sp = sp * 1.2
# if ssp > 850:
# ssp = ssp * 1.4
# price = bp + sp + ssp
# return int(price)
# else:
# bp = 3000 # Base Price
# sp = 0
# for stat in char.stats:
# if stat not in ["disposition", "joy", "health", "vitality"]: #, "mood"
# sp += getattr(char, stat)
# if sp > 1200:
# sp = sp * 1.2
# price = bp + sp
# return int(price)
# else:
# devlog.warning("get_price for {} was ran even though character is free !".format(char.id))
return 1000
def get_upkeep(self):
# TODO: To be revised after skills are added!
char = self.instance
if char.status == 'slave':
return 50
else:
return 0
# if char.status == 'slave':
# if 'Prostitute' in char.basetraits:
# bu = 20 * char.rank
# su = char.charisma/10 + char.refinement*1.5 + char.constitution/5 + char.reputation/2 + char.fame/2 # Stats Upkeep
# ssu = char.anal/8 + char.normalsex/8 + char.blowjob/8 + char.lesbian/8
# return int(bu + su + ssu + char.upkeep)
# elif traits['Stripper'] in char.occupations:
# bu = 3 * char.strip
# su = char.charisma/10 + char.refinement*1.5 + char.constitution/5 + char.reputation/2 + char.fame/2 # Stats Upkeep
# return int(bu + su + char.upkeep)
# elif 'Server' in char.occupations:
# bu = 3 * char.service
# su = char.charisma/10 + char.refinement*1.5 + char.constitution/5 + char.reputation/2 + char.fame/2 # Stats Upkeep
# return int(bu + su + char.upkeep)
# else:
# bu = 20
# su = 0 # Stats Upkeep
# for stat in char.stats:
# if stat not in ["disposition", "joy", "health", "vitality", "mood"]:
# su += getattr(char, stat)
# return int(bu + su + char.upkeep)
# elif char.status == 'free':
# return char.upkeep
# else: # This is for any unknown types
# bu = 50
# su = 0 # Stats Upkeep
# for stat in char.stats:
# if stat not in ["disposition", "joy", "health", "vitality", "mood"]:
# su += getattr(char, stat)
# return int(bu + su + char.upkeep)
def get_whore_price(self):
"""
Workprice for girls working as whores.
"""
# TODO: To be revised after skills are added!
char = self.instance
# if char.rank < 4:
# bp = 10 * char.rank # Base Price
# elif char.rank < 7 :
# bp = 15 * char.rank
# else:
# bp = 20 * char.rank
# sp = char.charisma/2 + char.refinement/3 + char.reputation/4 + char.fame/4 # Stats Price
# ssp = (char.anal + char.normalsex + char.blowjob + char.lesbian)/4*(1+(char.rank*0.1)) # Sex Stats Price
return 100 # int(bp + sp + ssp)
def next_day(self):
self.game_fin_log[str(day)] = (self.daily_income_log, self.daily_expense_log)
self.daily_income_log = dict(work=dict(), tips=dict(), private=dict())
self.daily_expense_log = dict(work=dict(), private=dict(), cost=dict())
class Stats(_object):
"""Holds and manages stats for PytCharacter Classes.
DEVNOTE: Be VERY careful when accesing this class directly!
Some of it's methods assume input from self.instance__setattr__ and do extra calculations!
"""
FIXED_MAX = set(['joy', 'mood', 'disposition', 'vitality', 'luck', 'alignment'])
def __init__(self, *args, **kwargs):
"""
instance = reference to Character object
Expects a dict with statname as key and a list of:
[stat, min, max, lvl_max] as value.
Added skills to this class... (Maybe move to a separate class if they get complex?).
DevNote: Training skills have a capital letter in them, action skills do not. This should be done thought the class of the character and NEVER using self.mod_skill directly!
"""
self.instance = args[0]
self.stats, self.imod, self.min, self.max, self.lvl_max = dict(), dict(), dict(), dict(), dict()
# Load the stat values:
for stat, values in kwargs.get("stats", {}).iteritems():
self.stats[stat] = values[0]
self.imod[stat] = 0
self.min[stat] = values[1]
self.max[stat] = values[2]
self.lvl_max[stat] = values[3]
# [action_value, training_value]
self.skills = {k: [0, 0] for k in self.instance.SKILLS}
# [actions_multi, training_multi, value_multi]
self.skills_multipliers = {k: [1, 1, 1] for k in self.skills}
# Leveling system assets:
self.goal = 1000
self.goal_increase = 1000
self.level = 1
self.exp = 0
# Statslog:
self.log = dict()
def _raw_skill(self, key):
"""Raw Skills:
[action_value, training_value]
"""
if key.islower(): return self.skills[key][0]
else: return self.skills[key.lower()][1]
def _get_stat(self, key):
maxval = self.get_max(key)
minval = self.min[key]
val = self.stats[key] + self.imod[key]
# Normalization:
if val > maxval:
if self.stats[key] > maxval:
self.stats[key] = maxval
val = maxval
elif val < minval:
if self.stats[key] < minval:
self.stats[key] = minval
val = minval
if key not in ["disposition", "luck"] and val < 0:
val = 0
return val
def is_skill(self, key):
# Easy check for skills.
return key.lower() in self.skills
def is_stat(self, key):
# Easy check for stats.
return key.lower() in self.stats
def normalize_stats(self, stats=None):
# Makes sure main stats dict is properly aligned to max/min values
if not stats:
stats = self.stats
for stat in stats:
val = self.stats[stat]
minval = self.min[stat]
maxval = self.get_max(stat)
if val > maxval:
self.stats[stat] = maxval
if val < minval:
self.stats[stat] = minval
def __getitem__(self, key):
return self._get_stat(key)
def __iter__(self):
return iter(self.stats)
def get_max(self, key):
val = min(self.max[key], self.lvl_max[key])
if key not in ["disposition"]:
if val < 0:
val = 0
return val
def mod_item_stat(self, key, value):
if key in self.stats:
self.imod[key] = self.imod[key] + value
def settle_effects(self, key, value):
if hasattr(self.instance, "effects"):
effects = self.instance.effects
if key == 'disposition':
if effects['Insecure']['active']:
if value >= 5:
self.instance.joy += 1
elif value <= -5:
self.instance.joy -= 1
if effects['Introvert']['active']:
value = int(value*.8)
elif effects['Extrovert']['active']:
value = int(value*1.2)
if effects['Loyal']['active'] and value < 0: # works together with other traits
value = int(value*.8)
if last_label.startswith("interactions_"):
tag = str(random.random())
renpy.show_screen("display_disposition", tag, value, 40, 530, 400, 1)
elif key == 'joy':
if effects['Impressible']['active']:
value = int(value*1.5)
elif effects['Calm']['active']:
value = int(value*0.5)
return value
def _mod_exp(self, value):
# Assumes input from setattr of self.instance:
if hasattr(self.instance, "effects"):
effects = self.instance.effects
if effects["Slow Learner"]["active"]:
val = value - self.exp
value = self.exp + int(round(val*.9))
if effects["Fast Learner"]["active"]:
val = value - self.exp
value = self.exp + int(round(val*1.1))
self.exp = value
while self.exp >= self.goal:
self.goal_increase += 1000
self.goal += self.goal_increase
self.level += 1
# Bonuses from traits:
for trait in self.instance.traits:
self.apply_trait_statsmod(trait)
# Normal Max stat Bonuses:
for stat in self.stats:
if stat not in self.FIXED_MAX:
self.lvl_max[stat] += 5
self.max[stat] += 2
# Chance to increase max stats permanently based on level
if self.level >= 20:
val = self.level / 20.0
if dice(val):
self.lvl_max[stat] +=1
if dice(val):
self.max[stat] +=1
# Super Bonuses from Base Traits:
if hasattr(self.instance, "traits"):
traits = self.instance.traits.basetraits
multiplier = 2 if len(traits) == 1 else 1
for trait in traits:
# Super Stat Bonuses: