⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 word.cpp

📁 网络游戏龙族 完整的登陆器 C++ 源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#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 + -