Git Product home page Git Product logo

xmas_random's Introduction

Xmas_random


项目介绍

该小程序的诞生起源于高中宿舍圣诞节互换礼物的抽签环节,如今我们六人已分隔四方,但我们很希望这个有趣的活动能够保留下来,故做了这个小程序,粗糙地满足随机匹配的需求。

包含文件

  • code.py 包含加密和解密方法的模块
  • Xmas_random_file.py / Xmas_random_wechat 前者本地生成密文本,后者微信在线发送密文
  • run_local.py / run_online.py 前者用于本地解密,后者用于在线解密

实现原理

  1. 加密和解密:详情请参见我的 encode_decode
  2. 随机匹配
    • give_dict 键值对记录送出的名字recv_dict键值对记录收到的状态
    • 过程:
      • 遍历成员
      • 保存当前成员收到的状态
      • 设置当前成员收到的状态为-1
      • 随机生成送出的名字并判断其收到的状态作出相应的操作
      • 还原当前成员收到的状态
      • 键值对打码
  3. 消息处理:详情请参见我的 Wechat 相关库

注意事项

  • run_online.py 中注意将 cipher 替换成自己对应的密文

如何运行

  1. 复制本目录下的所有文件至本地
  2. 可本地生成密文或微信在线发送密文:
    • 本地生成:打开相关解释器运行 Xmas_random_file.py,加密后的内容将写入 Xmas_random_file.txt
    • 微信发送:打开相关解释器运行 Xmas_random_wechat.py,参与抽签的人发送 Merry Xmas!,启动抽签的人发送 Magic!,密文即会自动发送
  3. 复制每个人对应的密文,选择一种解密方式进行解密即可:
    • 本地解密:打开相关解释器运行 run_local.py,按照提示输入密文即可
    • 在线解密:登录 https://c.runoob.com/compile/9 ,复制 run_online.py 并替换密文即可

Bug

  • 该小程序的私密性和专用性比较高,可扩展成更广泛适用的抽签器
  • 封装程度和代码结构还有待改进(尤其是保存原始状态那个函数)
  • 可能会出现两人互送暂时还未改进算法)和最后一个人只能送给自己只用断言判断报错,暂时无法自动解决)的情况
  • Xmas_random_wechat.py 暂时只支持同字长的备注名称,且要求启动抽签的人最后一个参与抽签

xmas_random's People

Contributors

lottewong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.