首页 > 新闻资讯  >  正文
转圈圈模拟器
2023-04-30 15:53:03 来源:哔哩哔哩

放在matlab里运行

无聊随便写了点怪东西


(资料图片仅供参考)

%date 2023/4/30

clear all;clc;

%% 生成怪

number = menu('对手数量','一个','两个','三个','四个','五个','随机(不大于五个)');

if number == 6

number = randi(5);

end

monster = (randi(501,1,number) + 499);

%% 攻击

attack = menu('发动一次攻击','平A','战技','终结技');

switch attack

case 1

way = 1;

damage = (randi(201) + 99);

case 2

way = menu('','单体','群体');

damage = (randi(301) + 299);s

case 3

way = menu('','单体','群体');

damage = (randi(301) + 499);

end

%% 判定

%伤害

blood1 = monster;

blood2 = blood1;

switch way

case 1

all = {''};

for i = 1:number

all(i) = {sprintf('%i',i)};

end

choice = menu('选择攻击目标',all);

blood2(choice) = blood1(choice) - damage;

case 2

blood2 = blood1 - damage;

end

%第一次判定

a = 0;

for n = 1:number

if blood2(n) < 1/2*monster(n)

a = a + 1;

end

end

blood1 = blood2;

count = 0;

%循环判定

while a >= 1

if blood1 < 0

break;

end

spin = randi(201) + 99;

blood2 = blood1 - a*spin;

count = count + a;

a = 0;

for n = 1:number

if blood2(n) < 1/2*monster(n) && blood1(n) > 1/2*monster(n)

a = a + 1;

end

end

end

%统计

dead = length(find(blood2<=0));

fprintf('黑塔转了%i圈,总计击倒了%i个敌人,场上还剩%i个敌人。',count,dead,number - dead);

标签:

精彩放送