2021年04月22日 23:05 __ _ _ _ _

文章配图

当你真正为自己、为好朋友或家人做一些事时,你就不会轻易放弃。但如果你不热爱这件事,那么你就不会多走一步,也不情愿在周末加班,只会安于现状。

文章配图

上回说到MOBA手游中最重要的是 英雄,那么其次于英雄的便属于英雄加成,在MOBA中表现为** 铭文装配 **
,这两者在游戏中对于游戏体验的作用是巨大的。

在MOBA手游中,虽然属性的加成不只是铭文,还有购买的装备,但开局前对铭文的装配,可以给英雄带来不少的提升,也有利于英雄前期的发育。

在MOBA手游中,不同的铭文会给英雄带来不同属性的增幅,每个英雄也有各自最适合的铭文搭配。

那么铭文属性的改变在代码中要如何处理呢,比如 铭文升级、铭文属性
的改变,铭文属性在每个等级之间的改变并不是固定的,一般来说是等级越高,属性的提升也越高。

由于铭文升级和装配都是在英雄开局前就设定好了的,所以在代码中只需考虑关于铭文的升级,
**一般表现形式是几个低级铭文可以合成一个等级更高的铭文,其中属性的提升是按照百分比提升的。
**

这一节分为了三个部分:

  1. 铭文初长成

  2. 铭文加持

  3. 铭文涅槃

第一部分挺简单的,是对 铭文属性的初始化

第二部分为铭文升级,需要注意的是升级后 **铭文属性的改变,以及原有铭文的数量。第三部分作为特列,演示了当我们铭文升级到最高等级时,不可再升级,也就是说在升级时 需要加上判断。 一.铭文初长成 源代码: **


# Todo:补全Rune类class RUne:# Todo:初始化属性name, color, attribute, attributeValue, level    def __init__(self, name, color, attribute, attributeValue, level):        self.name=name        self.color=color        self.attribute=attribute        self.attributeValue=attributeValue        self.level=level# Todo:在Rune类中打印输出属性的值        print("Rune:{},{},{},{},{}".format(self.name,self.color,self.attribute,self.attributeValue,self.level))
# Todo: 输入五行字符,按照顺序依次为Rune类对象的名称(name)、颜色(color)、属性名称(attribute)、属性值(attributeValue)、等级(level)初始化name=input()color=input()attribute=input()attributeValue=input()level=input()
# Todo:实例化Rune对象,打印输出结果 name,color,attribute,attributeValue,level
rune=RUne(name,color,attribute,attributeValue,level)

运行结果:

文章配图

二.铭文加持

源代码:


# Todo:补全Rune类class Rune:# Todo:初始化属性name, color, attribute, attributeValue, level    def __init__(self, name, color, attribute, attributeValue, level):        self.name = name        self.color = color        self.attribute = attribute        self.attributeValue = attributeValue        self.level = level
# Todo:  传入参数为:铭文数量,没有返回值。#       最初级的铭文为1级,5个1级铭文可以合成1个2级铭文,5个2级铭文可以合成3级铭文,以此类推.......#       铭文每提升一个等级,属性值增加20%。    def levelUp(self, number):        count=0        while (number>=5):            number=number//5            count+=1            self.attributeValue+=self.attributeValue*0.2        self.level+=count# 打印输出对象信息    def printObj(self):        self.attributeValue = round(self.attributeValue)        print('Rune:{0},{1},{2},{3},{4}'.format(self.name, self.color, self.attribute, self.attributeValue, self.level))
# Todo: 输入五行字符,按照顺序依次为Rune类对象的名称(name)、颜色(color)、属性名称(attribute)、属性值(attributeValue)、等级(level)初始化name=input()color=input()attribute=input()attributeValue=int(input())level=int(input())number=int(input())# Todo:实例化Rune对象rune=Rune(name,color,attribute,attributeValue,level)
# Todo:调用levelUp方法,实现铭文提升等级的功能rune.levelUp(number)
# Todo:调用printObj方法,打印输出对象信息rune.printObj()

**** ** 运行结果: **

文章配图

三.铭文涅槃

源代码:


# 初始化颜色等级限制的字典# 白色-3,绿色-5,蓝色-7,橙色-9,红色-12。dictLevel = {'白色': 3, '绿色': 5, '蓝色': 7, '橙色': 9, '红色': 12}

# Todo:补全Rune类class Rune:# Todo:初始化属性name, color, attribute, attributeValue, level    def __init__(self, name, color, attribute, attributeValue, level):        self.name = name        self.color = color        self.attribute = attribute        self.attributeValue = attributeValue        self.level = level
# Todo:  传入参数为:铭文数量,没有返回值。#       铭文每提升一个等级,属性值增加20%。#       铭文根据不同的颜色,提升等级的上限不同,白色-3,绿色-5,蓝色-7,橙色-9,红色-12。#       达到等级上限,铭文等级不可提升    def levelUp(self, number):        t0=number        i=1        while number>5:            if self.level<dictLevel[self.color]:                number=t0/(5**i)                self.level+=1                self.attributeValue*=1.2                i+=1            else:                print("已经达到铭文等级上限,不可再升级")                break            pass
# 打印输出对象信息    def printObj(self):        self.attributeValue = round(self.attributeValue)        print('Rune:{0},{1},{2},{3},{4}'.format(self.name, self.color, self.attribute, self.attributeValue, self.level))
# Todo: 输入五行字符,按照顺序依次为Rune类对象的名称(name)、颜色(color)、属性名称(attribute)、属性值(attributeValue)、等级(level)初始化name=input()color=input()attribute=input()attributeValue=int(input())level=int(input())number=int(input())
rune=Rune(name,color,attribute,attributeValue,level)
# Todo:调用levelUp方法,实现铭文提升等级的功能rune.levelUp(number)
# Todo:调用printObj方法,打印输出对象信息rune.printObj()

运行结果:

文章配图

未完待续…

文章配图

文章配图

为你,千千万万遍.

往期推荐:

Python模拟MOBA手游~英雄篇 2021-04-16
文章配图

华为云高校联盟活动~Python模拟MOBA手游(三) 2021-04-11
文章配图

三月碎碎念 || Q1总结 2021-04-03
文章配图

一键三连,就差你了
文章配图

预览时标签不可点

阅读




__