mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
更新
This commit is contained in:
parent
07db3912cc
commit
5a9ab02b54
@ -107,11 +107,13 @@ export default class GOnHookManager extends Singleton{
|
||||
//删除
|
||||
this.killSreeps.splice(index,1);
|
||||
|
||||
//通知添加野怪被删除
|
||||
app.event.emit(GOnHookManagerEvent.DEL_KILL_SREEP,creeps);
|
||||
|
||||
// //通知添加野怪被删除
|
||||
// if(await GAPI.GOnHookSellCreeps(creeps.key)){
|
||||
// return true;
|
||||
// }else{
|
||||
// }
|
||||
return await GAPI.GOnHookSellCreeps(creeps.key);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.retry.RetryException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -98,9 +99,17 @@ public class GOnHookController {
|
||||
//找到野怪删除
|
||||
if(Objects.isNull(creeps = CREEPS.get(player.getPlayerId()))) return NewsResource.onFail("卖出失败",false);
|
||||
|
||||
if(Objects.nonNull(creeps.remove(creepId))){
|
||||
GOnHookMessage.GOnHookPet onHookPet = creeps.remove(creepId);
|
||||
if(Objects.nonNull(onHookPet)){
|
||||
Resource res;
|
||||
//增加玩家金币 (默认添加100)
|
||||
Resource res = resourceService.addResourceValue(player.getPlayerId(), ResourceId.Gold.id, 100L);
|
||||
try{
|
||||
res = resourceService.addResourceValue(player.getPlayerId(), ResourceId.Gold.id, 100L);
|
||||
}catch (RetryException e){
|
||||
//出售失败
|
||||
creeps.put(creepId,onHookPet); //放回去
|
||||
throw new RetryException("");
|
||||
}
|
||||
return NewsResource.onSuccess(
|
||||
"卖出成功",
|
||||
true,
|
||||
|
@ -40,17 +40,37 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
res = this.initResource(playerId,type);
|
||||
}
|
||||
|
||||
//添加资源
|
||||
res.setResourceValue(res.getResourceValue() + value);
|
||||
if(value > 0){
|
||||
|
||||
if(res.getResourceValue() <= 0){
|
||||
return null;
|
||||
//如果是累加 则 执行累加sql
|
||||
if(this.update(
|
||||
Wrappers.lambdaUpdate(Resource.class)
|
||||
.eq(Resource::getPlayerId, playerId) //玩家
|
||||
.eq(Resource::getResourceTbId, type) //资源
|
||||
.setSql("resource_value = resource_value + "+value)
|
||||
)){
|
||||
//添加资源
|
||||
res.setResourceValue(res.getResourceValue() + value);
|
||||
return res;
|
||||
}else{
|
||||
throw new RetryException("");
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
//添加资源
|
||||
res.setResourceValue(res.getResourceValue() + value);
|
||||
|
||||
if(res.getResourceValue() <= 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
//保存资源 (保存失败重试)
|
||||
if (!this.saveOrUpdate(res)) throw new RetryException("");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//保存资源 (保存失败重试)
|
||||
if (!this.saveOrUpdate(res)) throw new RetryException("");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//初始化某个资源
|
||||
|
Loading…
x
Reference in New Issue
Block a user