签到与活动配置:后台配置接口、用户签到流程、UserEntity 扩展
This commit is contained in:
@@ -1186,6 +1186,32 @@ namespace FishGameService.GameService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 机器人击杀累计经验并在游戏内升级(按 UserLevelConfigs 判定,等级上限与经验上限封顶)。
|
||||
/// </summary>
|
||||
private void AddBotExp(RedisGamePlayer bot, long gainExp)
|
||||
{
|
||||
if (bot == null || gainExp <= 0)
|
||||
return;
|
||||
|
||||
bot.Exp = bot.Exp > long.MaxValue - gainExp ? long.MaxValue : bot.Exp + gainExp;
|
||||
|
||||
var configs = _gameConfig?.UserLevelConfigs;
|
||||
if (configs == null || configs.Count == 0)
|
||||
return;
|
||||
|
||||
var levelCfg = configs.FirstOrDefault(c => bot.Exp >= c.ExpMin && bot.Exp < c.ExpMax)
|
||||
?? configs.OrderBy(c => c.Level).LastOrDefault();
|
||||
|
||||
if (levelCfg == null)
|
||||
return;
|
||||
|
||||
bot.Level = levelCfg.Level;
|
||||
bot.MaxExp = levelCfg.ExpMax;
|
||||
if (bot.Exp >= levelCfg.ExpMax)
|
||||
bot.Exp = levelCfg.ExpMax - 1;
|
||||
}
|
||||
|
||||
private void AddBullets(string roomId, string userId, List<string> bulletIds)
|
||||
{
|
||||
_bulletTracker.Add(roomId, userId, bulletIds);
|
||||
@@ -1848,7 +1874,11 @@ namespace FishGameService.GameService
|
||||
skillGold = res.gold;
|
||||
bot.Gold = skillGold > long.MaxValue - bot.Gold ? long.MaxValue : bot.Gold + skillGold;
|
||||
|
||||
_sendResult.RoomKillNotice(roomId, fishNumber, botUserId, skillGold, fishId, DateTime.Now.ToTimeStamp(), res.beishu, gold, fishConfig.FishScore, res.res);
|
||||
var botExpGain = fishConfig.FishType is FishTypeEnum.Boss鱼 or FishTypeEnum.特殊鱼 or FishTypeEnum.特殊Boss
|
||||
? 1000 : fishConfig.FishScore;
|
||||
AddBotExp(bot, botExpGain);
|
||||
|
||||
_sendResult.RoomKillNotice(roomId, fishNumber, botUserId, skillGold, fishId, DateTime.Now.ToTimeStamp(), res.beishu, gold, fishConfig.FishScore, res.res, gainExp: botExpGain, exp: bot.Exp, level: bot.Level, expMax: bot.MaxExp);
|
||||
await FishKillControl(cid, room, bot, fishNumber, skillGold, fishId, gold, DateTime.Now.ToTimeStamp(), killConfig);
|
||||
}
|
||||
|
||||
@@ -1959,10 +1989,6 @@ namespace FishGameService.GameService
|
||||
var cannonMultiple = roomConfig.CannonMultipleList[System.Random.Shared.Next(roomConfig.CannonMultipleList.Count)];
|
||||
var maxMultiple = roomConfig.CannonMultipleList.Max();
|
||||
var gold = maxMultiple * System.Random.Shared.Next(100, 501);
|
||||
var props = _gameConfig?.PropConfig ?? new List<PropInfConfig>();
|
||||
var cannons = props.Where(p => p.Type == ProductTypeEnum.炮台 && p.IsEnable && !p.Number.StartsWith("401")).ToList();
|
||||
var wings = props.Where(p => p.Type == ProductTypeEnum.翅膀 && p.IsEnable && p.IsSale).ToList();
|
||||
var warGods = props.Where(p => p.Type == ProductTypeEnum.战神 && p.IsEnable && p.IsSale).ToList();
|
||||
|
||||
var replacementId = Guid.NewGuid().ToString("N");
|
||||
var replacementNumber = Common.Utils.RandomHelper.RandomNumbers(8);
|
||||
@@ -1972,16 +1998,10 @@ namespace FishGameService.GameService
|
||||
UserNumber = replacementNumber,
|
||||
UserName = profile.Name,
|
||||
Avatar = profile.Avatar,
|
||||
Level = System.Random.Shared.Next(1, 101),
|
||||
IsBot = true,
|
||||
Gold = gold,
|
||||
Diamond = System.Random.Shared.Next(100, 5001),
|
||||
Position = position,
|
||||
CannonId = cannons.Count > 0 ? cannons[System.Random.Shared.Next(cannons.Count)].Number : string.Empty,
|
||||
WingsId = wings.Count > 0 ? wings[System.Random.Shared.Next(wings.Count)].Number : string.Empty,
|
||||
WarGodId = warGods.Count > 0 && System.Random.Shared.Next(5) == 0
|
||||
? warGods[System.Random.Shared.Next(warGods.Count)].Number
|
||||
: string.Empty,
|
||||
CannonMultiple = cannonMultiple,
|
||||
BeginCoin = gold,
|
||||
BeginTime = DateTime.Now.ToTimeStamp(),
|
||||
@@ -1989,6 +2009,7 @@ namespace FishGameService.GameService
|
||||
State = 0,
|
||||
PlayerFactor = new PlayerFactor()
|
||||
};
|
||||
RoomBotFactory.ApplyBotBaseValues(replacement, _gameConfig);
|
||||
|
||||
room.Players.Add(replacement);
|
||||
NormalizeRoomPlayerCounts(room);
|
||||
@@ -2038,10 +2059,6 @@ namespace FishGameService.GameService
|
||||
int botsToCreate = Math.Min(room.RobotCount, availablePositions.Count);
|
||||
|
||||
|
||||
var cannons = _gameConfig.PropConfig.Where(p => p.Type == ProductTypeEnum.炮台 && p.IsEnable && !p.Number.StartsWith("401")).ToList();
|
||||
var wings = _gameConfig.PropConfig.Where(p => p.Type == ProductTypeEnum.翅膀 && p.IsEnable && p.IsSale).ToList();
|
||||
var warGods = _gameConfig.PropConfig.Where(p => p.Type == ProductTypeEnum.战神 && p.IsEnable && p.IsSale).ToList();
|
||||
|
||||
for (int i = 0; i < botsToCreate; i++)
|
||||
{
|
||||
var idx = System.Random.Shared.Next(botProfiles.Count);
|
||||
@@ -2058,16 +2075,10 @@ namespace FishGameService.GameService
|
||||
UserNumber = botNumber,
|
||||
UserName = profile.Name,
|
||||
Avatar = profile.Avatar,
|
||||
Level = System.Random.Shared.Next(1, 101),
|
||||
IsBot = true,
|
||||
Gold = gold,
|
||||
Diamond = System.Random.Shared.Next(100, 1001),
|
||||
Position = position,
|
||||
CannonId = cannons.Count > 0 ? cannons[System.Random.Shared.Next(cannons.Count)].Number : string.Empty,
|
||||
WingsId = wings.Count > 0 ? wings[System.Random.Shared.Next(wings.Count)].Number : string.Empty,
|
||||
WarGodId = warGods.Count > 0 && System.Random.Shared.Next(5) == 0
|
||||
? warGods[System.Random.Shared.Next(warGods.Count)].Number
|
||||
: string.Empty,
|
||||
CannonMultiple = roomConfig.CannonMultipleList[cannonIndex],
|
||||
BeginCoin = gold,
|
||||
BeginTime = DateTime.Now.ToTimeStamp(),
|
||||
@@ -2075,6 +2086,7 @@ namespace FishGameService.GameService
|
||||
State = 0,
|
||||
PlayerFactor = new PlayerFactor()
|
||||
};
|
||||
RoomBotFactory.ApplyBotBaseValues(bot, _gameConfig);
|
||||
|
||||
room.Players.Add(bot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user