python3 项目开发-中级篇

这个是学习python的中期项目,由一个团队完成的,团队人数为5-8人。我们团队是6个人。

首先,聊天室是由团队每个 人都要编写的,这个是通讯基础。

24点游戏规则比较简单,只需要将可行的24点组合提前存入到数据库,然后在适当的时候调用一个查询语句,随机出来一个组合,显示给所有用户,然后接收用户输入,判断表达式是否运算结果为24,如果是则提示正确,不是不做处理,当作正常聊天信息即可,这样用户可以自己想玩就玩,不想玩可以继续聊天。此部分代码由一个人来完成。

然后是天黑请闭眼游戏,该游戏稍微复杂一些,主要需要处理以下几个情景:(代码2人完成)

1:分牌给10位玩家,系统保存记录玩家的身份信息

2,while group == 魏国 or  魏国全部出局: #循环判断在游戏中的所有玩家是否只有一个阵营的

    1, 天黑时,魏国3人可以输入消息和接收消息,选择攻击目标,此时其他玩家接收不到消息,也无法发送消息,这样实现了天黑请闭眼的效果,攻击目标出局。异常输入处理:有且只有一个出局。

n=fun() -> return number

online.remove(n)

    2,魏国3人完成之后,这3人无法收到消息,3个蜀国的玩家可以选择查验一位玩家的身份,原则上是查看3位以外的玩家的身份信息,系统会告知3人被查验的人身份信息。 此时调用的函数和前面是基本一样的。有且只能查一个人身份。

    3,天亮了,系统提示步骤1情况下,被攻击目标出局的消息给的所有人,出局者此时被屏蔽掉任何消息。

    4,所有在游戏中的人自由讨论,此时所有在游戏中玩家可以接收任何消息,讨论时间为150s。

    5,时间到了,系统给每个客户端弹框,单选一个认定需要出局的人员,如果前没有任何玩家比其他玩家票数都高,则无人出局,否则票数最高者出局。

    6,如果有出局者,则此时出局者发表遗言,其他人全部不能发送消息,只能接收到出局者的遗言消息。

else:

    打印胜利的组的信息,以及原始人员的身份信息。

24点代码如下:

class TwentyFour:
        def __init__:
            pass
        def createCard(self):
            """store some tight group of 24"""
            pass
        def getFourCard(self,*args): -> return a sequence of 4 card
            1,create 4 card which can make up 24 by some math operation
        def showCards(self):
            """print 4 cards"""
        def getInputResult(self,*args):  -> return  result 
            2,get input expression,return it's result
            eg: 6*8+(7-5) -> 24
        def AnswerRight(self,result):
            result True if result == 24 else False
    if __name__ == "__main__":
        tf = TwentyFour()
        tf.xxx()
        tf.xxx()

天黑请闭眼代码如下:

class ThreeCountry:
        """game description:
            this game usual palyed by 10 players,3 of them belong to 'wei',
            3 of them belong to 'shu',orher 4 player belong to 'wu'.
            'shu' group and 'wu' group fight against to 'wei',but all of them 
            don't each other belong to which country,so they need comunicate.
            one turn:
                1,wei group decide which player out game(for example p1 out),meanwhile other player will not recv any message,timeout 15s,if no choice,default out the first player which not belong to wei.
                2,shu group decide which player to be shown,and the system will tell them the player belong to which group.meanwhile other player will not recv any message,timeout 15s,if no choice,default out the first player which not belong to shu
                3,system msg: player 1 out to all player,and player 1 cant send any msg to others.
                4,online player can send and recv any msg ,they can say anything,timeout 150s
                5,decide one player out game,player input the choice,server count the vote result ,and decide one player out. 
                Exception situation:
                    p1 = 4 p2 = 4, result is no player out
                    p1 no vote , this vote is 0,count other vote. 
            game over:
                1:wei group offline -> shu and wu win the game
                2:shu group and wu group offline  -> wei win the game
        """
        def __init__(self):
            pass

        def sendMsgtoWei(self):
            pass

        def recvResultFromWei(self):
            """return tuple('1','5',5')"""
            pass

        def defaultNoResultFromWei(self):
            """if goal is not sure,return a current default value"""

        def defaultFirstResultFromWei(self):
            """
                if goal is 5,1,7, return 5
                if goal is 7,1,5, return 7
            """

        def outPlayer(self,*args):
            """outPlayer('1','5',5') --> online.remove(5)"""
            """outPlayer('1') --> online.remove('1')"""
            pass

        def timeout(self,times):
            """set timeout time,unit= second(s)"""

        def sendMsgtoShu(self):
            pass

        def recvResultFromShu(self):
            """return tuple('1','5',5')"""
            pass

        def defaultNoResultFromShu(self):
            """if goal is not sure,return a current default value"""

        def defaultFirstResultFromShu(self):
            """
                if goal is 5,1,7, return 5
                if goal is 7,1,5, return 7
            """ 

        def vote(self):
            """
            return sequence of vote result
            format:("1","2","5","8","9"...)
            """

亮点内容来了:

    自动阅卷考试系统:

    1,进入考试系统前提示用户,考试期间不允许切屏,如果切屏3次则立即交卷处理

        此处需要编写函数

        a,不允许切屏函数,将界面全屏或者设置焦点不能改变

        b,计数函数,累计切屏次数

        c,切屏3次情况下,获取当前已选题目的结果,然后将界面关闭,将该用户从服务器端暂时拉黑掉。

    2,账号登陆 注册等,此处添加加密算法,实现拦截其他非法用户进行登陆注册等,避免泄露题目和答案,给使用服务器端公司带来损失。

    3,完全进入考试环境

        a,主界面用网页的方式打开,里面的内容使用一个函数来得到funName(singleList,dualList)

        b,函数funName(singleList,dualList)的功能是获取到题目,singleList传入的是一个随机数生成的列表,表示从数据库题库里面去取出这些数据,长度为30. dualList参数传入的是多选题的序号,这个序号用来从数据库的另外一张表里获取题目和答案,答案存入到一个答案列表里面,所以返回值是单选题的答案和多选题答案的两个列表。

        c,编写函数获取每个题目答案的方法

        d,编写提交试卷时,循环50次调用c中的方法,给到服务器端进行处理

        e,服务器接收到提交的答案之后,对答案进行解析,然后和funName返回的答案进行比对,得到最后的分数,以及提供一个接口函数,如果用户需要查看详细答案信息,可以查看到,但是不查看时只显示分数。

        f,设定答案给出的时间,必须是在考试设定的时间结束之后,所以用户考试都结束了,用户才能得到自己的分数和答案详细解释。

    说明:此程序需要大量的题目,所以这个工作量还是比较大的,但是为了开发和扩展,还需要编写能够批量导入数据的函数,这个函数能够根据指定的格式解析题目内容,答案和详细解释,分别存到数据库表中的字段里面,这样在后期数据量大的时候就可以批量的去增加,删除和修改数据了,便于数据库的维护。

    另外,数据库的查询语句也可以编写成为一些数据库的函数,这样在需要的时候直接调用这些函数即可。

    数据安全性方面一定要做好,数据的维护的工作量是很大的,所以这些前期的函数都要写的安全可靠,封装起来,后面维护的时候就直接调用,而不是每次都去使用基础的数据库语句了。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值