试做游戏

原创 2015年11月18日 19:04:19

‼️  这里没有类


//
//  main.m
//  试做
//
//  Created by 刘佳斌 on 15/11/17.
//  Copyright © 2015年 刘佳斌. All rights reserved.
//

/*
1、定义一个英雄类、怪物类、技能类、武器类、衣服类
2、英雄类:名字、攻击力、血量、防御力、初始技能、初始武器、初始化装备
3、怪物类:名字、攻击力、血量、防御力
4、技能类:名字、伤害
5、武器类:名字、伤害
6、衣服类:名字、防御
7、英雄可以使用选择武器、衣服、技能的方法
8、怪物可以使用技能 的方法
*/

#import <Foundation/Foundation.h>
#import "Hero.h"
#import "Monster.h"
#import "Skills.h"
#import "Weapons.h"
#import "Clothes.h"
#import "NSString+Input.h"
#import "stdlib.h"
int main(int argc, const char * argv[]) {
    
    @autoreleasepool {
        int heroPower = 0;
        int monHp = 0;
        int monDef = 0;
        
        Hero *wuKong = [[Hero alloc] init];
        [wuKong setHeName:@"悟空"];
        [wuKong setHePower:150];
        [wuKong setHeHp:900];
        [wuKong setHeDef:60];
     
        
        Hero *baJie = [[Hero alloc] init];
        [baJie setHeName:@"八戒"];
        [baJie setHePower:100];
        [baJie setHeHp:600];
        [baJie setHeDef:80];
        
        Monster *baiGuJing = [[Monster alloc]init];
        [baiGuJing setMoName:@"白骨精"];
        [baiGuJing setMoPower:60];
        [baiGuJing setMoHp:400];
        [baiGuJing setMoDef:30];
        
        Monster *hongHai = [[Monster alloc]init];
        [hongHai setMoName:@"红孩儿"];
        [hongHai setMoPower:100];
        [hongHai setMoHp:500];
        [hongHai setMoDef:50];
        
        Skills *heroS1 = [[Skills alloc]init];
        [heroS1 setSkName:@"平砍"];
        [heroS1 setSkPower:50];
        
        Skills *heroS2 = [[Skills alloc]init];
        [heroS2 setSkName:@"战吼"];
        [heroS2 setSkPower:80];
        
        Skills *heroS3 = [[Skills alloc]init];
        [heroS3 setSkName:@"怒杀"];
        [heroS3 setSkPower:150];
        
        Weapons *weapon1 = [[Weapons alloc]init];
        [weapon1 setWeName:@"菜刀"];
        [weapon1 setWePower:10];
        
        Weapons *weapon2 = [[Weapons alloc]init];
        [weapon2 setWeName:@"金箍棒"];
        [weapon2 setWePower:50];
        
        Weapons *weapon3 = [[Weapons alloc]init];
        [weapon3 setWeName:@"猪耙"];
        [weapon3 setWePower:30];
        
        Clothes *cloth1 = [[Clothes alloc]init];
        [cloth1 setClName:@"布衣"];
        [cloth1 setClDef:30];
        
        Clothes *cloth2 = [[Clothes alloc]init];
        [cloth2 setClName:@"锁子甲"];
        [cloth2 setClDef:50];
        
        Clothes *cloth3 = [[Clothes alloc]init];
        [cloth3 setClName:@"兰盾"];
        [cloth3 setClDef:80];
        
        
        NSLog(@"请选择你要的英雄 1.孙悟空       2.猪八戒    ");
        NSString *get = [NSString getInputString];
        
        if ([get isEqualToString:@"1"]) {
            NSLog(@"你选择了悟空");
            NSLog(@"你选择了%@,他的战斗力为%d,血量有%d,防御力为%d,初始技能%@,初始武器%@,初始装备%@",[wuKong getHeName],[wuKong getHePower],[wuKong getHeHp],[wuKong getHeDef],[heroS1 getSkName],[weapon1 getWeName],[cloth1 getClName]);
            heroPower = [wuKong getHePower];  //把攻击力赋值给全局变量
        }
        else if([get isEqualToString:@"2"]){
           NSLog(@"你选择了%@,他的战斗力为%d,血量有%d,防御力为%d,初始技能%@,初始武器%@,初始装备%@",[baJie getHeName],[baJie getHePower],[baJie getHeHp],[baJie getHeDef],[heroS1 getSkName],[weapon1 getWeName],[cloth1 getClName]);
            heroPower = [baJie getHePower];  //把攻击力赋值给全局变量
        }
        NSLog(@"请选择是否装备武器  1.YES    2.NO");
        NSString *get1 = [NSString getInputString];
        if ([get1 isEqualToString:@"1"]) {
            NSLog(@"请选择你要的武器 1.菜刀       2.金箍棒      3.猪耙");
            NSString *getW = [NSString getInputString];
            if ([getW isEqualToString:@"1"]&&[get isEqualToString:@"1"]) {
                NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon1 getWeName],[wuKong getHeName],[wuKong getHePower]+[weapon1 getWePower]);
                heroPower += [weapon1 getWePower];
            }
            else if ([getW isEqualToString:@"1"]&&[get isEqualToString:@"2"])
            {
             NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon1 getWeName],[baJie getHeName],[baJie getHePower]+[weapon1 getWePower]);
                heroPower += [weapon1 getWePower];
            }
            else if ([getW isEqualToString:@"2"]&&[get isEqualToString:@"1"])
            {
            NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon2 getWeName],[wuKong getHeName],[wuKong getHePower]+[weapon2 getWePower]);
                 heroPower += [weapon2 getWePower];
            }
            else if ([getW isEqualToString:@"2"]&&[get isEqualToString:@"2"])
            {
             NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon2 getWeName],[baJie getHeName],[baJie getHePower]+[weapon2 getWePower]);
                heroPower += [weapon2 getWePower];
            }
            else if ([getW isEqualToString:@"3"]&&[get isEqualToString:@"1"])
            {
                NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon3 getWeName],[wuKong getHeName],[wuKong getHePower]+[weapon3 getWePower]);
                 heroPower += [weapon3 getWePower];
            }
            else if ([getW isEqualToString:@"3"]&&[get isEqualToString:@"2"])
            {
            NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon3 getWeName],[baJie getHeName],[baJie getHePower]+[weapon3 getWePower]);
                 heroPower += [weapon3 getWePower];
            }
            
        }
        else
        {
            if ([get isEqualToString:@"1"]) {
                NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon1 getWeName],[wuKong getHeName],[wuKong getHePower]+[weapon1 getWePower]);
                heroPower += [weapon1 getWePower];
            }
            else if ([get isEqualToString:@"2"]){
             NSLog(@"你选择了%@,此时英雄%@的战斗力为%d",[weapon1 getWeName],[baJie getHeName],[baJie getHePower]+[weapon1 getWePower]);
                heroPower += [weapon1 getWePower];
            }
        }
        
        NSLog(@"请选择是否装备衣服  1.YES    2.NO");
        NSString *get2 = [NSString getInputString];
        if([get2 isEqualToString:@"1"]){
            NSLog(@"请选择要选择的衣服  1.布衣    2.锁子甲     3.兰盾");
            NSString *getC = [NSString getInputString];
            if ([getC isEqualToString:@"1"]&&[get isEqualToString:@"1"])  {
                NSLog(@"你选择了%@,此时英雄%@的防御力为%d",[cloth1 getClName],[wuKong getHeName],[wuKong getHeDef]+[cloth1 getClDef]);
            }
            else if ([getC isEqualToString:@"1"]&&[get isEqualToString:@"2"]){
            NSLog(@"你选择了%@,此时英雄%@的防御力为%d",[cloth1 getClName],[baJie getHeName],[baJie getHeDef]+[cloth1 getClDef]);
            }
            
            else if ([getC isEqualToString:@"2"]&&[get isEqualToString:@"1"])
            {
            NSLog(@"你选择了%@,此时英雄%@的防御力为%d",[cloth2 getClName],[wuKong getHeName],[wuKong getHeDef]+[cloth2 getClDef]);
            }
            
            else if ([getC isEqualToString:@"2"]&&[get isEqualToString:@"2"])
            {
            NSLog(@"你选择了%@,此时英雄%@的防御力为%d",[cloth2 getClName],[baJie getHeName],[baJie getHeDef]+[cloth2 getClDef]);
            }
            
            else if ([getC isEqualToString:@"3"]&&[get isEqualToString:@"1"])
            {
             NSLog(@"你选择了%@,此时英雄%@的防御力为%d",[cloth1 getClName],[wuKong getHeName],[wuKong getHeDef]+[cloth1 getClDef]);
            }
            
            else if([getC isEqualToString:@"3"]&&[get isEqualToString:@"2"])
            {
             NSLog(@"你选择了%@,此时英雄%@的防御力为%d",[cloth3 getClName],[baJie getHeName],[baJie getHeDef]+[cloth3 getClDef]);
            }
        }
        NSLog(@"夜深人静杀人夜...");
        NSString *get3 = [NSString stringWithFormat:@"%d",arc4random()%2+1];  //将随机数格式转换成字符
        if ([get3 isEqualToString:@"1"]) {
            NSLog(@"%@出现,她的血量为%d,防御为%d",[baiGuJing getMoName],[baiGuJing getMoHp],[baiGuJing getMoDef]);
            monHp = [baiGuJing getMoHp];
            monDef = [baiGuJing getMoDef];
        }
        else if ([get3 isEqualToString:@"2"])
        {
            NSLog(@"%@出现,她的血量为%d,防御为%d",[hongHai getMoName],[hongHai getMoHp],[hongHai getMoDef]);
            monHp = [hongHai getMoHp];
            monDef = [hongHai getMoDef];
            
        }
        
        NSLog(@"攻击吧少年");
        
        while (1) {
            NSLog(@"选择攻击技能  1.平砍   2.战吼   3.怒杀");
            NSString *getS = [NSString getInputString];
            if([getS isEqualToString:@"1"]){
                heroPower += [heroS1 getSkPower];
                monHp = monHp - heroPower + monDef;
                heroPower -= [heroS1 getSkPower];
                if(monHp <= 0){
                    NSLog(@"妖怪死了");exit(0);
                }
                else NSLog(@"妖怪血量还有%d",monHp);
            }
            else if([getS isEqualToString:@"2"])
            {
                heroPower += [heroS2 getSkPower];
                monHp = monHp - heroPower + monDef;
                heroPower -= [heroS2 getSkPower];
                if(monHp <= 0){
                    NSLog(@"妖怪死了");exit(0);
                }
                else NSLog(@"妖怪血量还有%d",monHp);
            }
            else if ([getS isEqualToString:@"3"])
            {
                heroPower += [heroS3 getSkPower];
                monHp = monHp - heroPower + monDef;
                heroPower -= [heroS3 getSkPower];
                if(monHp <= 0){
                    NSLog(@"妖怪死了"); exit(0);
                }
                else NSLog(@"妖怪血量还有%d",monHp);
            }
                
        }
        
    }
    return 0;
}








版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

webpack+vue.js+elementUI试做后台管理页面

前言由于上次搭好了SSM后端框架,就想着顺便把以前那个博客网站的后台管理系统给做了,系统的后端环境是有了,前端页面用什么开发呢?之前简单的看了vue.js,所以就决定用vue.js做前端页面,然后搜了...

ACE INVADER ga02试做2型

  • 2011-02-11 01:40
  • 3.38MB
  • 下载

第五届蓝桥杯C/C++本科B组(真题试做)(9~10)

第九题 迷宫取宝 标题:地宫取宝 X 国王有一个地宫宝库。是 n x m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。 地宫的入口在左上角,出口在右下角。 ...

使用UDK自带的skeleton mesh 和 animation 试做简易动画

简述: 使用UDK自带的mesh和Animation在matinee里做一个动画,后面还要研究一下怎么做动画并导入UDK。。 步骤: 1. 在场景中拖入一个skeletalMesh ...
  • anialy
  • anialy
  • 2012-06-19 14:55
  • 3307

第五届蓝桥杯C/C++本科B组(真题试做)(6~8)

终于考完……不过挂科的铁定的了。 还是来做题吧。 前面八道题做起来都很简单。 F: 标题:奇怪的分式 上小学的时候,小明经常自己发明新算法。一次,老师出的题目是: 1/...

EX0-101試做題

  • 2012-12-20 16:44
  • 19KB
  • 下载

用enfold主题试做了个网站

(连载)一步一步教你做黑白棋游戏(五)

本篇将会是这个游戏图形化界面的核心,如何将逻辑和绘图联系,真正吧界面做出来~ 其实各位应该已经想到了,在前面的绘图讲解中的那个绘图函数是通过像素操作进行绘图的,那么逻辑处理中也是二维数组的处理,很容...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)