码迷,mamicode.com
首页 > 其他好文 > 详细

简单的恋爱养成游戏

时间:2017-08-20 15:52:28      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:ase   lov   val   ini   eve   没有   one   logs   mon   

‘‘‘本来想做一个恋爱养成类的游戏,但因为时间限制,简化了一些行为,比如money参数和talk函数,就没有用到。
可以对各个函数再添加一个money参数值的选项,另,文本实在写不出来,talk就鸽了。‘‘‘
import random   #做一个选项冲突的设定。哪怕满足好感度等条件,也有三分之一的概率选择拒绝。
class Role(object):
    def __init__(self, name, sex, money, love_value):
        self.name = name
        self.sex = sex
        self.money = money
        self.love_value = love_value

    def talk(self, name, word):
        self.word = word
        print([%s] says: [%s] % (self.name, self.word))

class Player(Role):
    def work(self, money):  #本来想添加工作函数,以便对money有更多的扩展。。。。
        self.money = money
        print([%s] is going to work to earn money. % self.name)
        money += 1000

    def visit(self, Role1):
        self.Role1 = Role1
        print(I`m meeting [%s], and his/her love_value is [%s]% (Role1.name, Role1.love_value))

    def date(self, Role1):
        self.Role1 = Role1
        if Role1.love_value >= 30:
            if random.randint(1, 3) != 2:
                print(okay, i would be like to go out for a date with you.)
                Role1.love_value += 10
            else:
                print(sorry, but i have another plan.)
        else:
            print(sorry, i don`t want to date with you.)

    def shopping(self, Role1):
        self.Role1 = Role1
        if random.randint(1, 3) != 2:
            print(yeah, i really want to buy something.)
            self.money -= 1000
            Role1.love_value += 10
        else:
            print(sorry, i am busy now, may be we can go shopping next time.)

    def hotel(self, Role1):
        self.Role1 = Role1
        if Role1.love_value >= 80:
            if random.randint(1, 3) != 2:
                print(Yeah baby, may be we can try some new style this night.)
                self.money -= 2000
                Role1.love_value += 10
            else:
                print(i am tired today, let`s do it tomorrow.)
        else:
            print(no, i don`t think it`s the right time to do this, eh...)
            Role1.love_value -= 10

Jack = Player(Jack, M, 10000, 0)
Rose = Role(Rose, F, 10000, 50)
Linda = Role(Linda, F, 10000, 20)
Mark = Role(Mark, M, 10000, 0)


print(**100)
Jack.talk(Rose, hello darling)
print(Game Start!)
print(The player of this game is Jack, and his purpose is to chase one Role_Player. The player have 3 times to try everyday.)
print(**100)
day = 0
for day in range(5):
    print(day,[day])
    i=0
    for i in range(3):
        choice1 = input(whom do you want to visit? Rose? Linda? Mark?)
        if choice1 == Rose:
            Jack.visit(Rose)
            choice2 = input(what do you want to do ? date? shopping? hotel?)
            if choice2 == date:
                Jack.date(Rose)
            elif choice2 == shopping:
                Jack.shopping(Rose)
            elif choice2 == hotel:
                Jack.hotel(Rose)
            print(Rose.love_value)
            if Rose.love_value >= 100:
                print(Game over, and you have chased Rose.)
                break
            else:
                continue

        elif choice1 == Linda:
            Jack.visit(Linda)
            choice2 = input(what do you want to do ?date? shopping? hotel?)
            if choice2 == date:
                Jack.date(Linda)
            elif choice2 == shopping:
                Jack.shopping(Linda)
            elif choice2 == hotel:
                Jack.hotel(Linda)
            print(Linda.love_value)
            if Linda.love_value >= 100:
                print(Game over, you have chased Linda.)
                break
            else:
                continue
        elif choice1 == Mark:
            Jack.visit(Mark)
            choice2 = input(what do you want to do ?date? shopping? hotel?)
            if choice2 == date:
                Jack.date(Mark)
            elif choice2 == shopping:
                Jack.shopping(Mark)
            elif choice2 == hotel:
                Jack.hotel(Mark)
            print(Mark.love_value)
            if Mark.love_value >= 100:
                print(Game over, you have chased Mark.)
                break
            else:
                continue
        else:
            print(plz enter your choice again)
        i+=1
    day+=1
    if max(Rose.love_value, Linda.love_value, Mark.love_value)==100:
        break

    if day >=5 :
        print(sorry, you will be single all along.)

最后的visit选项那里,代码有些过于重复,先去逛个街,回头再想。。。。

简单的恋爱养成游戏

标签:ase   lov   val   ini   eve   没有   one   logs   mon   

原文地址:http://www.cnblogs.com/calvinsun/p/7399916.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!