public class RandomRed
{
private static List<award> allaward = new List<award>() {
new award(){chance=0.6,money=1},
new award(){chance=0.1,money=2},
new award(){chance=0.1,money=3},
new award(){chance=0.1,money=4},
new award(){chance=0.1,money=5},
};
private static Random Rnd = new Random();
public static decimal randommoney()
{
return (from x in Enumerable.Range(0, 1000000) //最多支100万次骰子
let oneaward = allaward[Rnd.Next(allaward.Count())]
let rand = Rnd.NextDouble() * 100
where rand < oneaward.chance
select oneaward).First().money;
}
public class award
{
public double chance { get; set; }
public decimal money { get; set; }
}
}
{
private static List<award> allaward = new List<award>() {
new award(){chance=0.6,money=1},
new award(){chance=0.1,money=2},
new award(){chance=0.1,money=3},
new award(){chance=0.1,money=4},
new award(){chance=0.1,money=5},
};
private static Random Rnd = new Random();
public static decimal randommoney()
{
return (from x in Enumerable.Range(0, 1000000) //最多支100万次骰子
let oneaward = allaward[Rnd.Next(allaward.Count())]
let rand = Rnd.NextDouble() * 100
where rand < oneaward.chance
select oneaward).First().money;
}
public class award
{
public double chance { get; set; }
public decimal money { get; set; }
}
}