赞 | 0 |
VIP | 10 |
好人卡 | 49 |
积分 | 10 |
经验 | 22958 |
最后登录 | 2020-8-1 |
在线时间 | 2161 小时 |
Lv3.寻梦者 酱油的
- 梦石
- 0
- 星屑
- 1020
- 在线时间
- 2161 小时
- 注册时间
- 2007-12-22
- 帖子
- 3271
|
隨機生成人物的實例 XDDDD 創意不錯。不過有些意見
話說我很懷疑這段的用途是甚麽....怎麼每個分歧都是一樣的==a
- cn = rand(3)
- cn_2 = rand(6)
- case cn_2
- when 0
- if $性别.include?("男")
- $data_actors[id].name = a+c+b
- end
- if $性别.include?("女")
- $data_actors[id].name = a1+c1+b1
- end
- when 1
- if $性别.include?("男")
- $data_actors[id].name = a+b+c
- end
- if $性别.include?("女")
- $data_actors[id].name = a1+b1+c1
- end
- when 2
- if $性别.include?("男")
- $data_actors[id].name = b+a+c
- end
- if $性别.include?("女")
- $data_actors[id].name = b1+a1+c1
- end
- when 3
- if $性别.include?("男")
- $data_actors[id].name = b+c+a
- end
- if $性别.include?("女")
- $data_actors[id].name = b1+c1+a1
- end
- when 4
- if $性别.include?("男")
- $data_actors[id].name = c+a+b
- end
- if $性别.include?("女")
- $data_actors[id].name = c1+a1+b1
- end
- when 5
- if $性别.include?("男")
- $data_actors[id].name = c+b+a
- end
- if $性别.include?("女")
- $data_actors[id].name = c1+b1+a1
- end
- end
复制代码
另外推薦你使用這種代碼:
name1 = %w[大 魔 金 小 龙 凤 花 云 仇 司马]
name2 = %w[恨 轩辕 萨 刚 花形 缺 笑谈 辟 鱼 雷]
name3 = %w[天 生 鲁 罗刹 成 吉 宇文 甘 泳 灵]
a = name1[rand(10)]
b = name2[rand(10)]
c = name3[rand(10)]
or
name1 = ["大","魔","金","小","龙","凤","花","云","仇","司马"]
name2 = ["恨","轩辕","萨","刚","花形","缺","笑谈","辟","鱼","雷"]
name3 = ["天","生","鲁","罗刹","成","吉","宇文","甘","泳","灵"]
a = name1[rand(10)]
b = name2[rand(10)]
c = name3[rand(10)]
隨便挑一種學(茶)
注釋很少(幾乎沒有),雖然禾西看得懂,但是用起來不是很方便。代碼不是很漂亮,應該要學習一下使用數組與Hash表 XD。 |
|