SQL冒险小游戏 语句

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

--建立一个Game数据库

CREA TE DA TABASE Game

ON PRIMARY

(NAME='Game',

FILENAME='E:\Search Game\Game.mdf',

SIZE=3MB,

MAXSIZE=UNLIMITED,

FILEGROWTH=1MB)

LOG ON(

NAME='Game_Log',

FILENAME='E:\Search Game\Game_Log.ldf',

SIZE=1MB,

MAXSIZE=UNLIMITED,

FILEGROWTH=1%)

GO

-----------------------------------------------------

--建立物件信息表thingInfo,利用可视化操作建立,略代码

--建立房间信息表roomInfo,利用可视化操作建立,略代码

--建立表inown,记录角色当前拥有的所有物品,略代码

--建立表location,记录角色当前位置,略代码

--建立表light,记录电筒的开头状态,略代码

------------------------------------------------------

------------------------复位数据库里各表的信息,重新开始游戏,reset------------------- create proc [reset]

as

begin

delete--first, delete all the infomation in the table

from thingInfo

insert into thingInfo--then, insert it with the default infomatin

select'flashlight','Desk','Office','exist'

union all

select'broccoli','Table','Dining Room','exist'

union all

select'apple','Table','Dining Room','exist'

union all

select'crackers','Desk','Office','exist'

union all

select'Nani','Washing machine','Cellar','Notyet'

delete

from inown

update location

set room='Hall'

update light

set On_Off='off'

print'Y ou can play again now'

end

--drop proc reset

--execute reset

-------------------------帮助(help)的存储过程---------------------

--

create proc help

as

begin

print

'

---------------------------------------------------

Hello, Welcome to Nani search adventure game!

Y our Role player as the adventurer is that of a three year

old. The Nani is your security blanket. It is getting

late and you are tired, but you can not go to sleep

without your Nani.

Y our mission is to find the Nani.

-------------------------------------------------

Use simple English sentences to enter commands.

The commands show bellow if you

Want to help ,you can use help (ex. help) Want to start again ,you can use reset (ex. reset)

Want to goto a room ,you can use go2 Room (ex. go2 office) Want to look around ,you can use look (ex. look)

Want to look in something ,you can use lookin Thing (ex. lookin desk) Want to take something ,you can use take Thing (ex. take apple) Want to drop something ,you can use release Thing (ex. release apple)

Want to eat something ,you can use eat Thing (ex. eat apple)

Want to turn on light ,you can use turnon Light (ex. turnon light)

Want to turn off light ,you can use turnoff Light (ex. turnoff light)

Want to inventory your things , you can use list (ex. list)

-------------------------------------------------

Enjoy your game

'

end

go

----------------------------创建go2 Room (ex. go2 office)---------------------

--

create proc go2

@aim varchar(25)

as

begin

declare @sql varchar(20)

select@sql=(select On_Off from light)

if((@aim='Cellar')and(@sql is null))

print'Y ou should go to find a flashligth'

else

if((@aim='Cellar')and(select On_Off from light)='off')

print'Y ou should take on the flashlight'

else

if(@aim =

(select next_room1

from roomInfo join location on roomInfo.room=location.room

where location.room=roomInfo.room )

or

@aim=

(select next_room2

from roomInfo join location on roomInfo.room=location.room

where location.room=roomInfo.room )

or

@aim=

(select next_room3

from roomInfo join location on roomInfo.room=location.room

where location.room=roomInfo.room ))

begin

update location set room=@aim

相关文档
最新文档