当前位置: 首页 > news >正文

无畏契约:源能行动-java模拟程序

以下是一个模拟无畏契约:源能行动游戏机制的 Java 程序

import java.util.*;

// 特工基类
abstract class Agent {
protected String name;
protected String role;
protected int health;
protected boolean isAlive;

public Agent(String name, String role) {
this.name = name;
this.role = role;
this.health = 100;
this.isAlive = true;
}

// 抽象方法 - 使用技能
public abstract void useAbility(int abilityNumber);

// 通用方法 - 受到伤害
public void takeDamage(int damage) {
if (isAlive) {
health -= damage;
if (health <= 0) {
health = 0;
isAlive = false;
System.out.println(name + " 已被击败!");
} else {
System.out.println(name + " 受到 " + damage + " 点伤害,剩余生命值: " + health);
}
}
}

// 通用方法 - 治疗
public void heal(int amount) {
if (isAlive) {
health += amount;
if (health > 100) health = 100;
System.out.println(name + " 恢复 " + amount + " 点生命值,当前生命值: " + health);
}
}

// Getter 方法
public String getName() { return name; }
public String getRole() { return role; }
public int getHealth() { return health; }
public boolean isAlive() { return isAlive; }
}

// 决斗者类
class Duelist extends Agent {
public Duelist(String name) {
super(name, "决斗者");
}

@Override
public void useAbility(int abilityNumber) {
switch(abilityNumber) {
case 1:
System.out.println(name + " 使用了冲刺技能,快速移动!");
break;
case 2:
System.out.println(name + " 使用了烟雾弹,遮挡视线!");
break;
case 3:
System.out.println(name + " 使用了致命射击,造成高额伤害!");
break;
case 4:
System.out.println(name + " 释放终极技能:死亡之眼!");
break;
default:
System.out.println("无效的技能选择!");
}
}
}

// 控场者类
class Controller extends Agent {
public Controller(String name) {
super(name, "控场者");
}

@Override
public void useAbility(int abilityNumber) {
switch(abilityNumber) {
case 1:
System.out.println(name + " 使用了烟雾屏障,阻挡视野!");
break;
case 2:
System.out.println(name + " 使用了闪光弹,致盲敌人!");
break;
case 3:
System.out.println(name + " 使用了减速区域,限制敌人移动!");
break;
case 4:
System.out.println(name + " 释放终极技能:全域封锁!");
break;
default:
System.out.println("无效的技能选择!");
}
}
}

// 先锋类
class Initiator extends Agent {
public Initiator(String name) {
super(name, "先锋");
}

@Override
public void useAbility(int abilityNumber) {
switch(abilityNumber) {
case 1:
System.out.println(name + " 使用了侦察箭,探测敌人位置!");
break;
case 2:
System.out.println(name + " 使用了冲击波,击退敌人!");
break;
case 3:
System.out.println(name + " 使用了震荡陷阱,眩晕敌人!");
break;
case 4:
System.out.println(name + " 释放终极技能:猎人之怒!");
break;
default:
System.out.println("无效的技能选择!");
}
}
}

// 守卫类
class Sentinel extends Agent {
public Sentinel(String name) {
super(name, "守卫");
}

@Override
public void useAbility(int abilityNumber) {
switch(abilityNumber) {
case 1:
System.out.println(name + " 部署了陷阱,限制敌人移动!");
break;
case 2:
System.out.println(name + " 设置了警报器,探测敌人!");
break;
case 3:
System.out.println(name + " 建立了防御屏障!");
break;
case 4:
System.out.println(name + " 释放终极技能:绝对防御!");
break;
default:
System.out.println("无效的技能选择!");
}
}
}

// 游戏回合类
class Round {
private int roundNumber;
private boolean attackersWin;

public Round(int roundNumber) {
this.roundNumber = roundNumber;
}

public void playRound(List<Agent> attackers, List<Agent> defenders) {
System.out.println("\n===== 第 " + roundNumber + " 回合开始 =====");

// 模拟回合战斗
Random random = new Random();

// 随机决定攻击方或防守方获胜
attackersWin = random.nextBoolean();

if (attackersWin) {
System.out.println("攻击方成功安放/拆除爆能器,攻击方获胜!");
// 随机选择一名防守方特工被击败
Agent defeatedDefender = defenders.get(random.nextInt(defenders.size()));
defeatedDefender.takeDamage(100);
} else {
System.out.println("防守方成功防守/拆除爆能器,防守方获胜!");
// 随机选择一名攻击方特工被击败
Agent defeatedAttacker = attackers.get(random.nextInt(attackers.size()));
defeatedAttacker.takeDamage(100);
}

// 随机使用技能
for (Agent agent : attackers) {
if (agent.isAlive()) {
agent.useAbility(random.nextInt(4) + 1);
}
}

for (Agent agent : defenders) {
if (agent.isAlive()) {
agent.useAbility(random.nextInt(4) + 1);
}
}
}

public boolean didAttackersWin() {
return attackersWin;
}
}

// 游戏类
public class ValorantSourceAction {
private List<Agent> attackers;
private List<Agent> defenders;
private int attackerScore;
private int defenderScore;
private int currentRound;

public ValorantSourceAction() {
this.attackers = new ArrayList<>();
this.defenders = new ArrayList<>();
this.attackerScore = 0;
this.defenderScore = 0;
this.currentRound = 1;
}

// 选择特工
public void selectAgents() {
System.out.println("===== 特工选择阶段 =====");

// 创建一些示例特工
attackers.add(new Duelist("捷风"));
attackers.add(new Initiator("猎枭"));
attackers.add(new Controller("幽影"));
attackers.add(new Duelist("雷兹"));
attackers.add(new Initiator("海神"));

defenders.add(new Sentinel("奇乐"));
defenders.add(new Sentinel("圣祈"));
defenders.add(new Controller("蝰蛇"));
defenders.add(new Duelist("菲尼克斯"));
defenders.add(new Sentinel("赛博"));

System.out.println("攻击方特工:");
for (Agent agent : attackers) {
System.out.println("- " + agent.getName() + " (" + agent.getRole() + ")");
}

System.out.println("\n防守方特工:");
for (Agent agent : defenders) {
System.out.println("- " + agent.getName() + " (" + agent.getRole() + ")");
}
}

// 玩游戏
public void playGame() {
System.out.println("\n===== 无畏契约:源能行动开始! =====");

selectAgents();

// 进行13回合比赛
while (currentRound <= 13 && attackerScore < 13 && defenderScore < 13) {
Round round = new Round(currentRound);
round.playRound(attackers, defenders);

if (round.didAttackersWin()) {
attackerScore++;
} else {
defenderScore++;
}

System.out.println("当前比分: 攻击方 " + attackerScore + " - " + defenderScore + " 防守方");
currentRound++;

// 每回合后暂停一下
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

// 宣布获胜者
System.out.println("\n===== 比赛结束! =====");
if (attackerScore > defenderScore) {
System.out.println("攻击方获胜! 最终比分: " + attackerScore + " - " + defenderScore);
} else {
System.out.println("防守方获胜! 最终比分: " + attackerScore + " - " + defenderScore);
}
}

public static void main(String[] args) {
ValorantSourceAction game = new ValorantSourceAction();
game.playGame();
}
}

http://www.dtcms.com/a/593948.html

相关文章:

  • 精通网站建设工资多少钱wordpress文章列表获取文章摘要
  • CSS盒模型的注意点
  • 海口网站建设团队自己做本地网站
  • 亚马逊旺季新规落地,跨境卖家如何打赢“物流时效战”?
  • 手机网站维护费微信的网站怎么做
  • 横向与竖向折叠屏手机形态分类及主要特点分析
  • 网站建设前期应该做哪些准备网络服务商在哪咨询
  • 进入职场第三课——立足
  • Android开发-java版学习笔记第三天
  • 长沙点梦网站建设学做衣服上什么网站好
  • SQL高效编程利器——深度解析四大核心应用场景下的数组计数方法
  • git工作流程
  • 网上商城网站建设设计方案怎样辨别自己网站的好坏
  • 安徽亳州建设厅网站员工信息查询系统
  • YOLOv5(三):Jupyter
  • 1.postman调用契约锁接口
  • 代刷网站推广如何用网站模板做网站
  • 前端学校网站开发视频教程廊坊设计网站公司
  • 实例介绍:Unittest框架及自动化测试实现流程
  • NAS 只在局域网能用?加上cpolar这样设置让文件访问不受限
  • web网页,在线%茶叶商城系统%系统demo,基于vscode,vue,java,jdk,springboot,mysql
  • 青岛seo网站管理网站这么推广
  • MATLAB数值分析方程求解方法详解
  • vue 不触发自动播放音频
  • 17做网站新塘牛仔城购物网站 英文介绍
  • 嘉兴建设工程造价信息网站如何做wordpress主题
  • 【把Linux“聊”明白】从冯诺依曼架构到操作系统
  • SEO 搜索优化测试环节深度解析:决定流量转化的隐性关键
  • NumPy性能密码:Python循环优化方法
  • 九洋建设官方网站wordpress 文章标题查询