<commit_before>local Class = require 'lib.hump.class'
local ModelComponent = getClass 'pud.component.ModelComponent'
local property = require 'pud.component.property'
local message = require 'pud.component.message'


-- CombatComponent
--
local CombatComponent = Class{name='CombatComponent',
	inherits=ModelComponent,
	function(self, properties)
		ModelComponent._addRequiredProperties(self, {
			'Attack',
			'Defense',
			'AttackBonus',
			'DefenseBonus',
		})
		ModelComponent.construct(self, properties)
	end
}

-- destructor
function CombatComponent:destroy()
	ModelComponent.destroy(self)
end

function CombatComponent:_setProperty(prop, data)
	prop = property(prop)
	if nil == data then data = property.default(prop) end

	if   prop == property('Attack')
		or prop == property('Defense')
		or prop == property('AttackBonus')
		or prop == property('DefenseBonus')
	then
		-- TODO: commented out because I'm giving strings right now, thinking I
		-- can support lua code in the property
		--verify('number', data)
	else
		error('CombatComponent does not support property: '..tostring(prop))
	end

	ModelComponent._setProperty(self, prop, data)
end


-- the class
return CombatComponent<commit_msg>add preliminary support to handle properties as lua strings<commit_after>local Class = require 'lib.hump.class'
local ModelComponent = getClass 'pud.component.ModelComponent'
local property = require 'pud.component.property'
local message = require 'pud.component.message'


-- CombatComponent
--
local CombatComponent = Class{name='CombatComponent',
	inherits=ModelComponent,
	function(self, properties)
		ModelComponent._addRequiredProperties(self, {
			'Attack',
			'Defense',
			'AttackBonus',
			'DefenseBonus',
		})
		ModelComponent.construct(self, properties)
	end
}

-- destructor
function CombatComponent:destroy()
	ModelComponent.destroy(self)
end

function CombatComponent:_setProperty(prop, data)
	prop = property(prop)
	if nil == data then data = property.default(prop) end

	if   prop == property('Attack')
		or prop == property('Defense')
		or prop == property('AttackBonus')
		or prop == property('DefenseBonus')
	then
		if type(data) == 'string' then
		else
			verify('number', data)
		end
	else
		error('CombatComponent does not support property: '..tostring(prop))
	end

	ModelComponent._setProperty(self, prop, data)
end


-- the class
return CombatComponent
{'fraction_non_alphanumeric': 0.1129777404451911, 'fraction_numerical': 0.0, 'mean_word_length': 5.092071611253197, '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': '7228307', 'n_tokens_mistral': 763, 'n_tokens_neox': 702, 'n_words': 189}