<commit_before>package models

import (
	"flag"
	"github.com/golang/glog"
	"github.com/jinzhu/gorm"
	"github.com/sintell/mmo-server/utils"
)

type Character struct {
	gorm.Model
	Attributes
	Stats
	Level   uint   `json: "level"`
	Name    string `json:"name" 		sql:"unique"`
	Class   string `json:"class"`
	UserID  uint
	Effects []*Effect `sql:"-"`
}

type CClass uint8

var defaultAttributes map[string]Attributes
var defaultStats map[string]Stats

func init() {
	flag.Parse()

	err := utils.LoadSetting(&defaultAttributes, "data/defaultAttributes.json")
	if err != nil {
		glog.Error("Can't load default attributes. Reason:", err.Error())
		panic(err.Error())
	}
	glog.Infof("Loaded default attributes: %i\n Total: %d", defaultAttributes, len(defaultAttributes))

	err = utils.LoadSetting(&defaultStats, "data/defaultStats.json")
	if err != nil {
		glog.Error("Can't load default stats. Reason:", err.Error())
		panic(err.Error())
	}
	glog.Infof("Loaded default stats: %i\n Total: %d", defaultStats, len(defaultStats))
}

func (this *Character) SetDefaults() {
	this.Stats = defaultStats[this.Class]
	this.Attributes = defaultAttributes[this.Class]

	this.HP = this.MaxHP
	this.MP = this.MaxMP
}

func (c *Character) ApplyEffect(effects ...*Effect) Character {
	return Character{}
}<commit_msg>[B] fix new character initilizataion<commit_after>package models

import (
	"flag"
	"github.com/golang/glog"
	"github.com/jinzhu/gorm"
	"github.com/sintell/mmo-server/utils"
	"strings"
)

type Character struct {
	gorm.Model
	Attributes
	Stats
	Level   uint   `json: "level"`
	Name    string `json:"name" 		sql:"unique"`
	Class   string `json:"class"`
	UserID  uint
	Effects []*Effect `sql:"-"`
}

type CClass uint8

var defaultAttributes map[string]Attributes
var defaultStats map[string]Stats

func init() {
	flag.Parse()

	err := utils.LoadSetting(&defaultAttributes, "data/defaultAttributes.json")
	if err != nil {
		glog.Error("Can't load default attributes. Reason:", err.Error())
		panic(err.Error())
	}
	glog.Infof("Loaded default attributes: %i\n Total: %d", defaultAttributes, len(defaultAttributes))

	err = utils.LoadSetting(&defaultStats, "data/defaultStats.json")
	if err != nil {
		glog.Error("Can't load default stats. Reason:", err.Error())
		panic(err.Error())
	}
	glog.Infof("Loaded default stats: %i\n Total: %d", defaultStats, len(defaultStats))
}

func (this *Character) SetDefaults() {
	this.Stats = defaultStats[strings.ToLower(this.Class)]
	this.Attributes = defaultAttributes[strings.ToLower(this.Class)]

	this.HP = this.MaxHP
	this.MP = this.MaxMP
	glog.Infof("Setting default stats for character %i:\nS : %i\nA : %i", this, defaultStats[this.Class], defaultAttributes[this.Class])
}

func (c *Character) ApplyEffect(effects ...*Effect) Character {
	return Character{}
}
{'fraction_non_alphanumeric': 0.1489971346704871, 'fraction_numerical': 0.0007163323782234957, 'mean_word_length': 4.8924050632911396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7206192', 'n_tokens_mistral': 976, 'n_tokens_neox': 945, 'n_words': 222}