?? word.cpp
字號:
#include "stdafx.h"
#include "Hangul.h"
#include "dragon.h"
#include "SmallMenuSet.h"
#include "Menu.h"
#include "SmallMenu.h"
#include "Hong_Sprite.h"
#include "stdio.h"
#include "String.h"
#include "convert565to555.h"
#include "Hong_Sub.h"
#include "tool.h"
#include "MenuSet.h"
#include "itemtable.h"
#include "skill.h"
#include "Effect.h"
#include "word.h"
#include <MATH.H>
#include "char.h"
extern void MouseClickPosition(int*,int*);
CPcWord pc_word[MAX_PCWORD]; // PC啊 富茄 郴儈吝 吝夸茄 竄絹
CPcWord npc_word[MAX_PCWORD]; // NPC啊 措翠且 府膠飄
CPcWord random_npc_word[MAX_PCWORD]; // NPC啊 Random欄肺 措翠且 府膠飄
char white_str[20][6];
char cmd[5][20];//lsw
static int start = 0;//lsw
static int start2 = 0;//lsw
static int start3 = 0;//lsw
char sell_text[10][10]; //lsw
char buy_text[10][10]; //lsw
char repair_text[10][10]; //lsw
//傍葷吝: 酒流 備泅 蹬瘤 臼籃 竊薦
//烙矯 葷儈吝: Test甫 困秦 烙矯利欄肺 葷儈吝牢 variables... and etc.
////////////////////////////////////////////////////////////////////////////////
// Function isThatMyItem
// Input: name of item
// Output: return true or false depense on owning the inputed item or not.
////////////////////////////////////////////////////////////////////////////////
bool isThatMyItem( char *item_name )
{
for( int a=0; a<3; a++ )
for( int b=0; b<3; b++ )
for( int c=0; c<8; c++ )
{
int item_no = InvItemAttr[a][b][c].item_no;
if( item_no )
{
char *my_item_name = GetItemName( item_no );
if( !strcmp( item_name, my_item_name ) ) return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////
// Function amountItem
// Input: name of item
// Output: number of items user has.
////////////////////////////////////////////////////////////////////////////
int amountItem( char *item_name )
{
int count = 0;
for( int a=0; a<3; a++ )
for( int b=0; b<3; b++ )
for( int c=0; c<8; c++ )
{
int item_no = InvItemAttr[a][b][c].item_no;
if( item_no )
{
char *my_item_name = GetItemName( item_no );
if( !strcmp( item_name, my_item_name ) ) count++;
}
}
return count;
}
////////////////////////////////////////////////////////////////////////////////////
// Function itemNameToNumber
// Input: The name of item.
// Output: The number of item.
////////////////////////////////////////////////////////////////////////////////////
int itemNameToNumber( char *item_name )
{
/*
#define ITEM_Plant_MAX 43
#define ITEM_Mineral_MAX 17
#define ITEM_Herb_MAX 63
#define ITEM_Cook_MAX 57
#define ITEM_Potion_MAX 64
#define ITEM_Tool_MAX 49
#define ITEM_Weapon_MAX 118
#define ITEM_Disposable_MAX 53
#define ITEM_Armor_MAX 122
#define ITEM_Accessory_MAX 177
#define ITEM_Etc_MAX 184
*/
int item_max[] = { ITEM_Plant_MAX, ITEM_Mineral_MAX ,
ITEM_Herb_MAX, ITEM_Cook_MAX ,
ITEM_Potion_MAX , ITEM_Tool_MAX ,
ITEM_Weapon_MAX , ITEM_Disposable_MAX ,
ITEM_Armor_MAX ,ITEM_Accessory_MAX ,
ITEM_Etc_MAX ,
};
for( int i=0; i<11; i++ )
{
for( int j=0; j<item_max[i]; j++ )
{
int item_no = i*1000+j;
char *source_item_name = GetItemName( item_no );
if( !strcmp( item_name, source_item_name ) ) return item_no;
}
}
return 0;
}
//ReqItemValue( item_no );
//////////////////////////////////////////////////////////////////////
// Function itemPrice
// return : Price of one.
// input : Name of Item.
//////////////////////////////////////////////////////////////////////
DWORD itemPriceWhenSell( char *item_name)
{
DWORD price = 0;
for( int a=0; a<3; a++ )
for( int b=0; b<3; b++ )
for( int c=0; c<8; c++ )
{
int item_no = InvItemAttr[a][b][c].item_no;
if( item_no )
{
char *my_item_name = GetItemName( item_no );
if( !strcmp( item_name, my_item_name ) )
{
return ( GetItemValueSell( InvItemAttr[a][b][c] ));
}
}
}
return 0; // The user doesn't have this item.
}
DWORD itemPriceWhenBuy( char *item_name)
{
DWORD price = 0;
for( int a=0; a<3; a++ )
for( int b=0; b<3; b++ )
for( int c=0; c<8; c++ )
{
int item_no = InvItemAttr[a][b][c].item_no;
if( item_no )
{
char *my_item_name = GetItemName( item_no );
if( !strcmp( item_name, my_item_name ) )
{
return ( (DWORD)GetItemValueBuy( InvItemAttr[a][b][c].item_no ));
}
}
}
return 0; // The user doesn't have this item.
}
// price = GetItemAttr(t.item_no, VALUE);
// price = (int)( (float)price/d_max*(d_max - d_curr)*DUR_RATIO +.5 );
///////////////////////////////////////////////////////////////////////////
// Erase usless words from input.
// return the inputed sentence without usless words.
///////////////////////////////////////////////////////////////////////////
char* getRidOfStuff( char *text )
{
if( !start2 )
{
for(int ii=0;ii<20; ii++)
{
strcpy(white_str[ii],lan->OutputMessage(7,ii+211));//lsw
}
start2 = 1;
}
for( int i=0; i<20; i++ )
{
if( white_str[i] )
{
char *ptr;
while( ptr = strstr( text, white_str[i] ) )
{
int len = strlen( white_str[i] );
for( int j=0; j<len; j++ )
*( ptr+j ) = ' ';
}
}
else break;
} /// 閡鞘夸茄 竄絹甫 絕局綽 累訣
return text;
}
////////////////////////////////////////////////////////////////////////////////
// This function finds out what kind of operation does it need.
// And return integers depense on the result.
////////////////////////////////////////////////////////////////////////////////
int whichCommand( char *text )
{
if( !start3 )
{
for(int ii=0;ii<10; ii++)
{
strcpy(sell_text[ii],lan->OutputMessage(7,ii+181));//lsw
}
for(ii=0;ii<10; ii++)
{
strcpy(buy_text[ii],lan->OutputMessage(7,ii+191));//lsw
}
for(ii=0;ii<10; ii++)
{
strcpy(repair_text[ii],lan->OutputMessage(7,ii+201));//lsw
}
start3 = 1;
}
for( int i=0; i<20; i++ )
{
if( (sell_text[i]) )
{
char *ptr = strstr( text, sell_text[i] );
if( ptr ) return 1; // selling command return 1.
}
}
for( i=0; i<20; i++ )
{
if( (buy_text[i]) )
{
char *ptr = strstr( text, buy_text[i] );
if( ptr ) return 2; // buying command return 2.
}
}
for( i=0; i<20; i++ )
{
if( (repair_text[i]) )
{
char *ptr = strstr( text, repair_text[i] );
if( ptr ) return 3; // repair command return 3.
}
}
return 0; // invalid command return 0.
}// End of function, whichCommand.
////////////////////////////////////////////////////////////////////////////
// 傍葷吝
// Function makeDeal: 蕊瀝 system
// void makeDeal(parameters) // inputed line from chat.
// No return value.
////////////////////////////////////////////////////////////////////////////
int makeDeal( LPSTR lpStr) //皋春俊輯 葷儈且 攫絹 矯膠袍
{
char* text = getRidOfStuff(lpStr); //get a text line without crap.
int operation = whichCommand(text); //which command do we need to excute.
char *word;
word = strtok( text, " \n");
char *name = NULL;
int amount = 0;
int costs = 0;
float dum = (0.8f + ((rand()%5)/10.0f)) ;
////////////////// Read in the name of item ///////////////////////
switch( operation )
{
case 1 : // command sell.
{
if( isThatMyItem( word ) )
{
char *temp_word;
temp_word = strtok( NULL, " \n");
amount = atoi( temp_word );
if( amount <= 0 ) return -200;// You don't have anything with you.
temp_word = strtok( NULL, " \n");
costs = atoi( temp_word);
if( costs <= 0 ) return -300;// Are you out of your mind?
// You don't want money for that item?
if(costs <= (amount * (itemPriceWhenSell(word))*dum))
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -