cannon: set count when loading wrong type of cannonballs
This commit is contained in:
@@ -384,6 +384,15 @@ public class CannonPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().startsWith("Your cannon contains"))
|
||||||
|
{
|
||||||
|
Matcher m = NUMBER_PATTERN.matcher(event.getMessage());
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
cballsLeft = Integer.parseInt(m.group());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getMessage().startsWith("You unload your cannon and receive Cannonball")
|
if (event.getMessage().startsWith("You unload your cannon and receive Cannonball")
|
||||||
|| event.getMessage().startsWith("You unload your cannon and receive Granite cannonball"))
|
|| event.getMessage().startsWith("You unload your cannon and receive Granite cannonball"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,6 +104,18 @@ public class CannonPluginTest
|
|||||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addWrongTypeOfCannonballs()
|
||||||
|
{
|
||||||
|
final ChatMessage message = new ChatMessage();
|
||||||
|
message.setType(ChatMessageType.GAMEMESSAGE);
|
||||||
|
message.setMessage("Your cannon contains 20 x Cannonball.<br>You can only add cannonballs of the same kind.");
|
||||||
|
|
||||||
|
plugin.onChatMessage(message);
|
||||||
|
|
||||||
|
assertEquals(20, plugin.getCballsLeft());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addMaxCannonballs()
|
public void addMaxCannonballs()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user