


Share small programs for pumping out restaurants and game equipment made by .net
This article mainly introduces the small program for smoking restaurants and game equipment produced by .net. Friends no longer have to think about where to eat every day. It is very fun and practical. Friends in need can refer to it
Just create a new asp.net web project and drag it in. Now I know why the game always fails to produce good equipment, because its weight is very small. . . For lunch, randomly select which restaurant you want to go to, and set the weight value a little higher. If you still can’t win, just accept your fate!
Default.aspx
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <title>加权随机</title>
Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { //<string>: public Dictionary<string> Goods = new Dictionary<string>(); public int TotalWeight = 0; public class Good { /// <summary> /// 名称 /// </summary> public string Name { get; set; } /// <summary> /// 权重(大于等于1,否则出现的可能性为0) /// </summary> public int Weight { get; set; } } public List<good> Result = new List<good>(); protected void Page_Load(object sender, EventArgs e) { } /// <summary> /// 初始化装备 俺是《梦三国》玩家,嘿嘿 /// </summary> protected void InitGoods() { Goods.Clear(); TotalWeight = 0; Goods.Add("寒冰爪", 2); //神器(拳爪类) Goods.Add("重毛皮", 300); Goods.Add("小毛皮", 1000); Goods.Add("轻毛皮", 1000); Goods.Add("神之防具打造书", 5); Goods.Add("传说武器打造书", 20); Goods.Add("紫檀树枝", 300); Goods.Add("硬毛皮", 600); Goods.Add("勾魂水晶", 8); Goods.Add("真龙炙舞剑", 30); Goods.Add("董卓勾魂", 1); //神器中的神器(长柄类) foreach (KeyValuePair<string> kvp in Goods) { TotalWeight += kvp.Value; } } /// <summary> /// 初始化餐厅,公司楼下餐厅比较多,只写几个,意思意思。。。 /// </summary> protected void InitFood() { Goods.Clear(); TotalWeight = 0; Goods.Add("清真兰州", 1); Goods.Add("长安客", 1); Goods.Add("迎客松", 1); Goods.Add("吉祥混沌", 1); foreach (KeyValuePair<string> kvp in Goods) { TotalWeight += kvp.Value; } } protected int GetTryParse() { try { return int.Parse(txtNum.Text); } catch { return 1; } } //开始抽奖(装备) protected void btnRandom_Click(object sender, EventArgs e) { InitGoods(); lblResult.Text = lblResult.Text + "<br>"; int Count = GetTryParse(); for (int i = 1; i kvp in Goods) { int c = Result.Count(d => d.Name == kvp.Key); double rate = c * 1.0 / Count * 1.0 * 100; lblResult.Text = lblResult.Text + "物品名称:" + kvp.Key + " 权重:" + kvp.Value + " 暴出次数:" + c.ToString() + " 暴出率:" + rate + "%<br>"; } } //开始抽奖(餐厅) protected void btnRandomFood_Click(object sender, EventArgs e) { InitFood(); lblResult.Text = lblResult.Text + "<br>"; int Count = GetTryParse(); for (int i = 1; i kvp in Goods) { int c = Result.Count(d => d.Name == kvp.Key); double rate = c * 1.0 / Count * 1.0 * 100; lblResult.Text = lblResult.Text + "餐厅名称:" + kvp.Key + " 权重:" + kvp.Value + " 暴出次数:" + c.ToString() + " 暴出率:" + rate + "%<br>"; } } /// <summary> /// 根据随机权重判断所在范围 /// </summary> /// <param> protected void ProduceResult(int Weight) { int min = 1; int max = 1; foreach (KeyValuePair<string> kvp in Goods) { max = min + kvp.Value - 1; if (Weight >= min && Weight /// 随机种子值(防止速度过快造成的重复) /// /// <returns></returns> private static int GetRandomSeed() { byte[] bytes = new byte[4]; System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); rng.GetBytes(bytes); return BitConverter.ToInt32(bytes, 0); } //清屏操作 protected void btnClear_Click(object sender, EventArgs e) { lblResult.Text = ""; } }</string></string></string></good></good></string></string></string>
The above is the entire content of this article, I hope you can like.
The above is the detailed content of Share small programs for pumping out restaurants and game equipment made by .net. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In daily work, we encounter a lot of things that require drawing lots. The traditional method is to randomly draw numbers using paper numbers. With the development of electronic software, we can use computers to draw lots. The lesson I want to share with you today is How to make an excel lottery applet. 1. First, we open the Excel software and open the table we prepared. The table must contain our names. 2. Then we merge the cells on the right, fill in black who is lucky tonight, and merge the cells below and fill in red, as shown in the figure below. 3. Then we enter the randbetween function in the red area and set the first line to 2 and the last line to 7, as shown in the figure below. 4. Then we enter ind in front

Whether you are a beginner or an experienced professional, mastering C# will pave the way for your career.

The development of artificial intelligence (AI) technologies is in full swing today, and they have shown great potential and influence in various fields. Today Dayao will share with you 4 .NET open source AI model LLM related project frameworks, hoping to provide you with some reference. https://github.com/YSGStudyHards/DotNetGuide/blob/main/docs/DotNet/DotNetProjectPicks.mdSemanticKernelSemanticKernel is an open source software development kit (SDK) designed to integrate large language models (LLM) such as OpenAI, Azure

Detailed explanation of the design and implementation of PHP lottery system 1. Overview Lottery is a marketing tool used by many websites and applications. Through lottery, it can attract users to participate in activities, increase user interactivity and improve user stickiness. In this article, we will introduce in detail how to use PHP language to design and implement a simple lottery system. By studying this article, readers will understand the construction principles and specific code implementation of the lottery system. 2. System Design Before designing a lottery system, we first need to determine the functional requirements and processes of the system. one

How to use Vue to implement lottery wheel special effects. As a popular marketing tool, lottery activities often appear in various activities. In order to increase fun and interactivity, we can use the Vue framework to implement a lottery wheel special effect. This article will introduce how to use Vue to achieve this special effect and give specific code examples. First, we need to create a Vue instance to control the status and animation of the turntable. In this example, we need to define the initial state of the wheel, including the prize list, whether the wheel is rotating,

Title: Steps and techniques for developing lottery functions using PHP. In website development, lottery functions are often used to increase user interactivity and attraction. Using PHP language to develop lottery functions is a common way. In this article, we will introduce how to use PHP to develop a simple lottery function and give specific code examples. Step 1: Prepare the database First, we need to create a MySQL database to store relevant data of the lottery, including prize information, participating user information, etc. You can use the following SQL command to create a

If you are a .NET developer, you must be aware of the importance of optimizing functionality and performance in delivering high-quality software. By making expert use of the provided resources and reducing website load times, you not only create a pleasant experience for your users but also reduce infrastructure costs.

In terms of high-concurrency request processing, .NETASP.NETCoreWebAPI performs better than JavaSpringMVC. The reasons include: AOT early compilation, which reduces startup time; more refined memory management, where developers are responsible for allocating and releasing object memory.
