# elephant-game-framework

> - 框架初始化

Latest version **4.0.0** (published 2021-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install elephant-game-framework
pnpm add elephant-game-framework
yarn add elephant-game-framework
bun add elephant-game-framework
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-04-26 |
| First published | 2020-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 4 |
| Unpacked size | 4.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Fish |
| Maintainers | jnufish |

## Links

- npm: https://www.npmjs.com/package/elephant-game-framework
- npm.io page: https://npm.io/package/elephant-game-framework

## Dependencies (4)

- [md5](https://npm.io/package/md5.md) ^2.3.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.0.0
- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.15

## Recent versions

- 4.0.0 (latest) — 2021-04-26
- 3.8.0 — 2021-04-02
- 3.7.0 — 2021-04-01
- 3.6.1 — 2021-03-29
- 3.6.0 — 2021-03-16
- 3.5.0 — 2021-02-05
- 3.4.0 — 2021-02-01
- 3.3.1 — 2021-01-14
- 3.3.0 — 2021-01-14
- 3.2.0 — 2020-12-28
- 3.1.0 — 2020-12-09
- 3.0.2 — 2020-11-30
- 3.0.1 — 2020-11-23
- 3.0.0 — 2020-11-18
- 2.18.0 — 2020-11-18
- … 88 more at https://npm.io/package/elephant-game-framework/versions

## README

# 大象互动游戏框架

-   框架初始化

```ts
// 创建全新的FeatureCenter
let featureCenter = FeatureHelper.buildFeatureCenter(AllFeatures) // 对应需要使用的FeatureCenter类
    .appendConfig(featureNames.Logging, { logConfig: EnvConfig.logConfig } as ILoggingFeatureConfig) // 调用appendConfig方法，添加FeatureConfig以配置各个Feature
    .appendConfig(featureNames.Advertise, EnvConfig.advertiseConfig)
    .build(); // 调用build生成featureCenter实例
GameFramework.initializeFramework(featureCenter); // 使用生成的featureCenter和特定的配置，初始化框架
```

-   调用 Feature 方法

```ts
// 通过FeatureHelper来执行对Feature的调用
let loginRet: boolean = await FeatureHelper.invokeFeature<LoginFeature>(
    featureNames.Login,
    (loginFeature: LoginFeature) => {
        return loginFeature.tryLogin(relogin);
    },
    false
);
```

-   日志

```ts
let logger = new FeatureLogger('test'); // FeatureLogger是日志类，test为日志对象名
logger.debug('debug log');
logger.info('info log');
logger.warn('warn log');
logger.error('error log');
logger.fatal('fatal log');
// 默认打印的日志格式：
[D - test@Feature] : debug info
```

-   API 接口

```ts
class TestApi extends ApiBase {
    construct() {
        super('test', '/test'); // ‘test’是api名称，日志打印会使用该名称；'/test'是Api的相对url路径
    }

    public getTestInfo(): Promise<any> {
        return this.get('/info'); // 调用get方法，发起一个get请求获取信息，返回对象是any
    }
}
```

## 更新日志

-   1.2.1

    -   优化框架导出

-   1.2.0

    -   修复 SDK 初始化失败的问题（Feature 参数获取失败）
    -   添加 SDK 加载的统计上报（开始加载/完成加载）
    -   优化框架代码组织结构

-   1.1.3

    -   修复观察者模式通知消息遍历的隐藏 BUG

-   1.1.2

    -   优化观察者模式模块的错误日志

-   1.1.0

    -   增加性能监控模块（本地调试版本）

-   1.0.0

    游戏框架第一版

---
_Source: https://npm.io/package/elephant-game-framework · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
