简单的恋爱养成游戏

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单的恋爱养成游戏相关的知识,希望对你有一定的参考价值。

‘‘‘本来想做一个恋爱养成类的游戏,但因为时间限制,简化了一些行为,比如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选项那里,代码有些过于重复,先去逛个街,回头再想。。。。

以上是关于简单的恋爱养成游戏的主要内容,如果未能解决你的问题,请参考以下文章

解密区块链宠物养成游戏系统(附代码)!

区块链宠物系统开发:你的游戏里宠物养成了吗?

给卖不出去的智能音箱出个主意:要不弄成恋爱养成游戏算了?

日本翻中的恋爱养成游戏

五子棋游戏(简单易懂,入门都能学)

区块链软件 NFT游戏开发养成类游戏