chat commands: add ba high gamble command

This commit is contained in:
Jacob McElroy
2019-06-27 08:50:32 -04:00
committed by Adam
parent 1e112f97d5
commit 8757d25bd3
6 changed files with 166 additions and 0 deletions

View File

@@ -107,6 +107,28 @@ public class ChatController
return kc;
}
@PostMapping("/gc")
public void submitGc(@RequestParam String name, @RequestParam int gc)
{
if (gc < 0)
{
return;
}
chatService.setGc(name, gc);
}
@GetMapping("/gc")
public int getKc(@RequestParam String name)
{
Integer gc = chatService.getGc(name);
if (gc == null)
{
throw new NotFoundException();
}
return gc;
}
@PostMapping("/task")
public void submitTask(@RequestParam String name, @RequestParam("task") String taskName, @RequestParam int amount,
@RequestParam int initialAmount, @RequestParam String location)

View File

@@ -139,4 +139,22 @@ public class ChatService
jedis.setex("pb." + boss + "." + name, (int) EXPIRE.getSeconds(), Integer.toString(pb));
}
}
public Integer getGc(String name)
{
String value;
try (Jedis jedis = jedisPool.getResource())
{
value = jedis.get("gc." + name);
}
return value == null ? null : Integer.parseInt(value);
}
public void setGc(String name, int gc)
{
try (Jedis jedis = jedisPool.getResource())
{
jedis.setex("gc." + name, (int) EXPIRE.getSeconds(), Integer.toString(gc));
}
}
}