评论

#小程序云开发挑战赛#-趣味游乐城-SuperQ

本文主要介绍了“趣味游乐城”的实现思路、功能架构、系统架构。

一、应用场景

本应用适合利用碎片休闲打发时间,通过游乐放松心情,感悟人生、扩展社交、增进友谊本应用最大的特色是处处充满随机,有道是人生如潮,有得意也总有失意,不总是按部就班,也正因为有很多不可预期,带了阵阵的惊喜或惊吓。

玩家以精灵视角穿行于游乐城,游玩各类游乐项目,通过抽取钻石盲盒获得钻石,拿钻石换取金币,用金币补充精灵和城堡的每日消耗,以及支付日常有趣社交。

二、目标用户

碎片闲暇用户

三、实现思路

用户无需注册,进入小程序即生成用户,获得原始金币。可通过盲盒寻宝获得钻石,兑换钻石获取金币,钻石价格每日波动,犹如股票,持有或出仓,是赚是赔皆无定数。人生处处有玄机,游戏中亦是如此。精灵、城堡每日消耗金币,需要不断赚取金币维持,偶或间碰到打家劫舍的,蚀财损物再所难免,偶或好友疏财相助,也不亦乐,行为的善恶关乎自己的魅力值。精灵魅力值、生命值,房屋的完善度关乎打劫和被打劫的金币、钻石数。

四、架构图

功能架构

系统架构

五、效果截图




六、功能代码展示

每日定时任务代码

// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
  env'***'})
const db = cloud.database()
const _ = db.command


// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  clearRecords()
  updateTreasurePrice()
  updateUserInfo()


  //清理record
  async function clearRecords() {
    let day = new Date(Date.now() - (3 * 24 * 60 * 60 * 1000 + 8 * 60 * 60 * 1000))
    console.log(day)
    let res = await db.collection('Record').where({
      createTime: _.lt(day)
    }).remove()
    console.log("clearRecords = 'ok'", res)
  }
  //更新宝石每日成交价
  async function updateTreasurePrice() {
    let res2 = await db.collection('Setting').doc('5a93cec95edf0fc400679b4f23f37a84')
      .get()
    let treasures = res2.data.treasures
    for (let i = 0; i < treasures.length; i++) {
      let rate = ((Math.random() * 20) - 10) / 100
      let price = Math.floor(treasures[i].price * (1 + rate))
      treasures[i].price = price
      treasures[i].rate = rate
    }


    await db.collection('Setting').doc('5a93cec95edf0fc400679b4f23f37a84')
      .update({
        data: {
          treasures: treasures
        }
      })
    console.log("updateTreasurePrice = 'ok'")
  }
  //更新用户每日
  async function updateUserInfo() {
    let day = new Date(Date.now() + (8 * 60 * 60 * 1000))
    let today = day.getFullYear().toString() + (day.getMonth() + 1).toString() + day.getDate().toString();


    let userCount = await db.collection('User').count()
    let total = userCount.total
    let list = []
    for (let j = 0; j < total; j += 100) {
      list = list.concat(await getList(j));
    }
    for (i = 0; i < list.length; i++) {
      let houseLife, roomSum
      if (list[i].house.roomSum == 0 && list[i].house.life <= 10) {
        houseLife = 0
        roomSum = 0
      } else if (list[i].house.roomSum > 0 && list[i].house.life <= 10) {
        houseLife = 100
        roomSum = list[i].house.roomSum - 1
      } else {
        houseLife = list[i].house.life - 10
        roomSum = list[i].house.roomSum
      }


      let life = list[i].pet.life < 4 ? list[i].pet.life : 4
      let charm = list[i].pet.charm < 4 ? list[i].pet.charm : 4


      //更新用户数据
      let res = await db.collection('User').doc(list[i]._id)
        .update({
          data: {
            loginDay: today,
            dialTimes0,
            openBoxTimes0,
            'house.life': houseLife,
            'house.roomSum': roomSum,
            'pet.life': _.inc(-life),
            'pet.charm': _.inc(-charm)
          }
        })
    }
    console.log("updateUserInfo = 'ok'")
  }


  async function getList(skip{
    let res = await db.collection('User')
      .skip(skip).get()
    return res.data;
  }


}

七、作品体验二维码

八、团队介绍

个人小程序开发爱好者。码云:https://gitee.com/kyalong/super-q-amusement-park

最后一次编辑于  2020-09-20  
点赞 11
收藏
评论

11 个评论

  • 小七
    小七
    2020-09-25

    这种养成的很有市场啊~

    不过目前看上去还差点东西 老哥还持续开发吗?

    方便的话可以加个微信 交流交流

    我:Xrw2021


    2020-09-25
    赞同 1
    回复
  • 禾店科技
    禾店科技
    2021-04-30

    很好呀,有源码吗。合作一下

    2021-04-30
    赞同 1
    回复
  • lwenm
    lwenm
    2020-09-22

    2020-09-22
    赞同 1
    回复
  • Running
    Running
    2021-03-07

    个人感觉这款小游戏缺乏核心玩法,即游戏的乐趣到底是什么?

    2021-03-07
    赞同
    回复
  • 刘洋(论文辅导+PPT)
    刘洋(论文辅导+PPT)
    2020-09-26

    有点好玩

    2020-09-26
    赞同
    回复
  • 2020-09-22

    为你点赞,

    大佬你的代码我可以使用吗?

    2020-09-22
    赞同
    回复 2
    • 风起雪飞
      风起雪飞
      2020-09-22
      随意使用,有不明白的还可以问我,我尽力解释,写得不好的地方的你也留言继续优化
      2020-09-22
      回复
    • 2020-09-22回复风起雪飞
      谢谢 大佬
      2020-09-22
      回复
  • 🇫 🇴 🇷 🇬 🇺 🇴
    🇫 🇴 🇷 🇬 🇺 🇴
    2020-09-21

    大佬

    2020-09-21
    赞同
    回复
  • 🇫 🇴 🇷 🇬 🇺 🇴
    🇫 🇴 🇷 🇬 🇺 🇴
    2020-09-21

    大佬

    2020-09-21
    赞同
    回复
  • 青寒
    青寒
    2020-09-21

    这个有点强啊

    2020-09-21
    赞同
    回复
  • 老腊肉不好吃
    老腊肉不好吃
    2020-09-10

    好强啊

    2020-09-10
    赞同
    回复

正在加载...

登录 后发表内容