← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug-1281823 into lp:widelands

 

no problem for me to rename

@SirVer - see answer to one of your comments below in diff.

Diff comments:

> === modified file 'src/scripting/lua_map.cc'
> --- src/scripting/lua_map.cc	2014-10-27 10:14:10 +0000
> +++ src/scripting/lua_map.cc	2014-11-26 20:51:03 +0000
> @@ -3501,6 +3501,7 @@
>  	PROP_RO(LuaField, viewpoint_y),
>  	PROP_RW(LuaField, resource),
>  	PROP_RW(LuaField, resource_amount),
> +	PROP_RO(LuaField, starting_resource_amount),
>  	PROP_RO(LuaField, claimers),
>  	PROP_RO(LuaField, owner),
>  	{nullptr, nullptr, nullptr},
> @@ -3660,10 +3661,21 @@
>  		report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", amount, max_amount);
>  
>  	field->set_resources(res, amount);
> +	field->set_starting_res_amount(amount);
>  
>  	return 0;
>  }
> -
> +/* RST
> +	.. attribute:: starting_resource_amount
> +
> +		(RO) Starting value of resource. It is set be resource_amount
> +
> +		:see also: :attr:`resource`
> +*/
> +int LuaField::get_starting_resource_amount(lua_State * L) {
> +	lua_pushuint32(L, fcoords(L).field->get_starting_res_amount());
> +	return 1;
> +}
>  /* RST
>  	.. attribute:: immovable
>  
> 
> === modified file 'src/scripting/lua_map.h'
> --- src/scripting/lua_map.h	2014-09-14 11:31:58 +0000
> +++ src/scripting/lua_map.h	2014-11-26 20:51:03 +0000
> @@ -942,6 +942,7 @@
>  	int set_resource(lua_State *);
>  	int get_resource_amount(lua_State *);
>  	int set_resource_amount(lua_State *);
> +	int get_starting_resource_amount(lua_State *);
>  	int get_claimers(lua_State *);
>  	int get_owner(lua_State *);
>  
> 
> === modified file 'test/maps/lua_testsuite.wmf/scripting/efield.lua'
> --- test/maps/lua_testsuite.wmf/scripting/efield.lua	2014-01-12 19:06:22 +0000
> +++ test/maps/lua_testsuite.wmf/scripting/efield.lua	2014-11-26 20:51:03 +0000
> @@ -11,5 +11,13 @@
>     assert_equal(0, self.f.resource_amount)
>  end
>  
> +function field_resources_tests:test_starting_resource_in_editor()
> +	-- making sure that (set_)	resource_amount sets also starting resource 
> +	assert_equal("coal", self.f.resource)

I dont understand a meaning of this comment. Why should we care that resource_amount!=starting_resource_amount here. In fact they will probably be equal. Depending on a map used for testing.

> +	self.f.resource_amount=10
> +	assert_equal(self.f.starting_resource_amount, self.f.resource_amount)
> +end
> +
> +
>  
>  
> 


-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1281823/+merge/242837
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1281823.


References