YYS达摩速成
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
namespace CodeDemo
{
public partial class yys : System.Web.UI.Page
{
private string _1N = "N"; //N卡
private string _1W = "W"; //白蛋
private string _1B = "B"; //蓝蛋
private string _1R = "R"; //红蛋
private string _3W = "3W"; //3星白蛋(一级)
private string _4W = "4W"; //4星白蛋(一级)
private int NCount = 0;
private int WCount = 0;
private int BCount = 0;
private int RCount = 0;
//特殊变量
private int W3Number = 0; //3星白蛋数量
private int W4Number = 0; //4星白蛋数量
private int B8Number = 0; //8级蓝达摩
private int B10Number = 0; //10级蓝达摩
private int B11Number = 0; //11级蓝达摩
int w4num = 5;
int w3num = 0;
protected void Page_Load(object sender, EventArgs e)
{
List list = new List();
int c = 0;
int ci = 0;
for(int i = 0; i < 5; i++)
{
ci++;
c = (w4num - (ci * 4) >= 0 ? 4 : w4num);
list.Add(Get5W(c, w3num));
w4num = (w4num - (ci * 4) <= 0 ? 0 : w4num - (ci * 4));
}
string result = JsonConvert.SerializeObject(list);
Response.Write(result);
Response.Write("
获取总共需要N卡" + NCount + "个,白达摩" + WCount + "个,蓝达摩" + BCount + "个,红达摩" + RCount + "个。
其中您需要额外准备一级的三星白达摩" + W3Number + "个,一级的四星白达摩" + W4Number + "个。
其中蓝达摩总共需要:" + B8Number + "个8级的蓝达摩," + B10Number + "个10级的蓝达摩," + B11Number + "个11级的蓝达摩。");
}
protected List Get5W(int W4num,int W3num)
{
List list_5W = new List();
//获取一个四星白达摩
list_5W.Add(Get4W(W3num));
//由于调用四星白达摩时核减过,需要重新赋值。
W3num = w3num;
//Response.Write("alert('" + w3num + "')");
//吃一个10级的蓝达摩
list_5W.Add(GetB(10));
//然后加4个四星白达摩,如果W4num>0,有一级的四星白达摩当材料就少添加一次四星白达摩
int a = 0;
int aj = 0;
for (int j=0;j< 4-W4num; j++)
{
//每次获取四星白达摩时,根据一级的三星白达摩数量进行核减
aj++;
a = (W3num - (aj * 3) >= 0 ? 3 : W3num);
list_5W.Add(Get4W(a));
W3num = (W3num - (aj * 3) <= 0 ? 0 : W3num - (aj * 3));
}
for (int j = 0; j < W4num; j++)
{
list_5W.Add(_4W);
W4Number++;
}
return list_5W;
}
///
///
///
/// 3星白蛋数量
///
protected List Get4W(int Wnum)
{
List list_4W = new List();
//取一个吃了蓝达摩经验溢出的三星白达摩
list_4W.Add(Get3W());
int d = Wnum - 3 >= 0 ? 3 : Wnum;
//然后加3张N卡,如果Wnum>0,有一级的三星白达摩当材料就少添加一次3星N卡
for (int k = 0; k < 3- d; k++)
{
list_4W.Add(Get3N());
}
for(int k=0;k< d; k++)
{
list_4W.Add(_3W);
W3Number++;
w3num = w3num-- <= 0 ? 0 : w3num--;
}
return list_4W;
}
protected List Get3W()
{
List list_3W = new List();
//一个白达摩
list_3W.Add(_1W);
//加一个11级的蓝达摩
list_3W.Add(GetB(11));
//再加两张N卡
list_3W.Add(_1N);
list_3W.Add(_1N);
NCount += 2;
WCount += 1;
return list_3W;
}
protected List Get3N()
{
List list_3N = new List();
list_3N.Add(_1N);
list_3N.Add(GetB(8));
list_3N.Add(_1N);
list_3N.Add(_1N);
NCount += 3;
return list_3N;
}
protected List GetB(int num)
{
List list_B = new List();
if (num == 8)
{
list_B.Add(_1B);
list_B.Add(_1R);
BCount += 1;
RCount += 1;
//统计8级蓝达摩数量
B8Number += 1;
}
else if (num == 10)
{
list_B.Add(_1B);
list_B.Add(_1R);
list_B.Add(_1R);
BCount += 1;
RCount += 2;
//统计10级蓝达摩数量
B10Number += 1;
}
else if (num == 11)
{
list_B.Add(_1B);
list_B.Add(_1R);
list_B.Add(_1R);
list_B.Add(_1R);
BCount += 1;
RCount += 3;
//统计11级蓝达摩数量
B11Number += 1;
}
return list_B;
}
}
}