khanat-client/ressources/scripts/creatures_old.gd

86 lines
2.1 KiB
GDScript3
Raw Permalink Normal View History

2020-03-21 09:10:26 +00:00
extends Node
class Creature_old2:
enum Sex { F, M, H, A, U }
var type
var pseudonym
2020-03-21 09:10:26 +00:00
func _init( p_pseudonym = "Créature" ):
self.type = "creature"
self.pseudonym = p_pseudonym
2020-03-21 09:10:26 +00:00
class Ra_old2 extends Creature_old2:
var sex = Creature_old2.Sex.F
var female_boobs = 0.0
var female_hip = 0.0
var male_pack = 0.0
var male_throat = 0.0
var female_pregnant = 0.0
var color = Color( 1.0, 1.0, 1.0 )
var douleur = 0.0
var trauma = 0.0
var oubli = 0.0
func _init( p_pseudonym = "Créature" ):
self.type = "ra"
self.pseudonym = p_pseudonym
2020-03-21 09:10:26 +00:00
func to_dictionary():
var dictionary = Dictionary()
dictionary[ "type" ] = self.type
dictionary[ "pseudonym" ] = self.pseudonym
dictionary[ "sex" ] = var2str( self.sex )
dictionary[ "female_boobs" ] = var2str( self.female_boobs )
dictionary[ "female_hip" ] = var2str( self.female_hip )
dictionary[ "male_pack" ] = var2str( self.male_pack )
dictionary[ "male_throat" ] = var2str( self.male_throat )
dictionary[ "female_pregnant" ] = var2str( self.female_pregnant )
dictionary[ "color" ] = var2str( self.color )
2020-03-21 09:10:26 +00:00
return dictionary
func from_dictionary( dictionary ):
self.pseudonym = dictionary.get( "pseudonym", self.pseudonym )
self.sex = dictionary.get( "sex", self.sex )
self.female_boobs = dictionary.get( "female_boobs", self.female_boobs )
self.female_hip = dictionary.get( "female_hip", self.female_hip )
self.male_pack = dictionary.get( "male_pack", self.male_pack )
self.male_throat = dictionary.get( "male_throat", self.male_throat )
self.female_pregnant = dictionary.get( "female_pregnant", self.female_pregnant )
self.color = dictionary.get( "color", self.color )
2020-03-21 09:10:26 +00:00
func from_file( filename ):
var file = File.new()
if file.file_exists( "user://creatures/" + filename ):
file.open( "user://creatures/" + filename, File.READ )
var lines = ""
while not file.eof_reached():
var current_line = file.get_line()
lines += current_line
var json = JSON.parse( lines ).result
var dict = {}
for data in json:
dict[ data ] = str2var( json[data] )
2020-03-21 09:10:26 +00:00
self.from_dictionary( dict )
file.close()
2020-03-21 09:10:26 +00:00