//玩家捐献爵位
public void Donation(PlayerObject play, GameStruct.MONEYTYPE type, int value)
{
const int MIN_GOLD = 3000000; //最低捐献金额- 防封包
GameStruct.GUANGJUELEVEL oldlv = play.GetGuanJue();
int gold = 0;
switch (type )
{
case GameStruct.MONEYTYPE.GOLD:
{
if (gold < MIN_GOLD)
{
play.LeftNotice("最低捐献" + MIN_GOLD.ToString() + "万金币起。");
return;
}
if (play.GetMoneyCount(GameStruct.MONEYTYPE.GOLD) < value)
{
play.LeftNotice("金币不足,无法捐献!");
return;
}
gold = value;
play.ChangeAttribute(GameStruct.UserAttribute.GOLD, -gold);
break;
}
case GameStruct.MONEYTYPE.GAMEGOLD:
{
if (play.GetMoneyCount(GameStruct.MONEYTYPE.GAMEGOLD) < value)
{
play.LeftNotice("魔石不足,无法捐献!");
return;
}
play.ChangeAttribute(GameStruct.UserAttribute.GAMEGOLD, -value);
//转换成金币 一个魔石等于7100金币
const int _gold = 7100;
gold = value * _gold;
if (gold < MIN_GOLD)
{
play.LeftNotice("最低捐献"+MIN_GOLD.ToString()+"万金币起。");
return;
}
break;
}
}
play.GetBaseAttr().guanjue += (uint)gold;
SetValue(play.GetBaseAttr().player_id,play.GetName() ,play.GetBaseAttr().guanjue);
//通知客户端
//重新计算一下等级
GameStruct.GUANGJUELEVEL level = this.GetLevel(play);
//爵位被改变- 发公告
if (oldlv != level)
{
this.SendChangeGuanJueMsg(play, level);
}
if (level != play.GetGuanJue())
{
play.SetGuanJue(level);
}
this.SendGuanJueInfo(play);
DB_Update(play);
}